I'm attempting to use Windsor and NHibernate in a medium trust environment and I'm running up against some problems with permissions. I have read through the other questions on this but I'm using Windsor's NHibernate facility which I haven't seen discussed.
For some reason there is a dependency on the Castle.Service.Transations assembly...
I'm starting to get into Unit Testing, Dependancy Injection and all that jazz while constructing my latest ASP.NET MVC project.
I'm to the point now where I would like to Unit Test my Controllers and I'm having difficulty figuring out how to appropriately do this without an IoC container.
Take for example a simple controller:
public c...
I've searched high and look for samples about using MEF for DI. I know its not DI but from what I hear (really hear in podcasts) it can be used as such...but I can't find any blog posts or samples.
I am using MEF in this project already (to support plugins) and thought it would be nice to leverage for DI also.
Maybe I am barking up the...
Today I've got this class:
public class SmtpEmailProvider : IMessageProvider
{
private readonly SmtpClientWrapper _smtpClientWrapper;
public SmtpEmailProvider(SmtpClientWrapper smtpClientWrapper)
{
_smtpClientWrapper = smtpClientWrapper;
}
To be able to mock the SmtpClient, I've wrapped it like this:
public c...
Is there some kind of a shorthand fluent interface for creating a parameters dictionary to be provided to the IWindsorContainer.Resolve() method? Something like:
container.Resolve<ConsoleApp>(Parameters.Add("args", args).Add("banana", X).Add...)
...
Wherever possible I use TDD:
I mock out my interfaces
I use IOC so my mocked ojbects can be injected
I ensure my tests run and that the coverage increases and I am happy.
then...
I create derived classes that actually do stuff, like going to a database, or writing to a message queue etc.
This is where code coverage decreases - an...
Hi,
When using a IOC library like ninja, is there a performance cost to this or is it a one-time hit during application_start mostly?
...
I'm introducing an IoC Container in an architecture for the first time. I'm looking for things that one should not do with an IoC Container. I want to avoid the pitfalls of using an IoC container. I don't want to misuse or overuse it.
Can you help me put up a list of things to avoid when using a IoC container?
I have on item on my list...
I use contructor injection in my solution, but this one class has a property that i do not want to pass in the constructor where i have the invariant dependencies.
Let's say i got an ILogger and it has a FileName property i want to set, while still having it set the dependancies in the contructor.
How do i go about registering the type,...
I am trying to register the following class using the fluent interface:
public class DirectorySync : IDirectorySync
{
public DirectorySync(DirectoryInfo sourceDir, DirectoryInfo targetDir)
{
_sourceDirectory = sourceDir;
_targetDirectory = targetDir;
}
}
How do I go about specifying the DirectoryInfo instances? They shou...
Lately I've been using a larger number of smaller objects, because they are simpler and easier to reuse. Most of the time there isn't any problem injecting these objects into one another using StructureMap (great tool, btw). But occasionally, I f*** up, and I get myself a nice circular reference in the guise of a stack overflow excepti...
I've been thinking about the IApplicationContext.GetObject(string name) method and it seems to rely fairly heavily on magic strings to get objects from the application context. With other containers like StructureMap you can use generics to specify the configuration and request objects but is there a better way than using strings with th...
I have the following bit of registration code:
Component.For<IPublishingService>().ImplementedBy<UseStoredProcedureToPrintService>(),
Component.For<IConfirmationDialog<AutomatedTransaction>>().ImplementedBy<ShipmentConfirmationDialog>().Named("ShipmentConfirmationDialog"),
Component.For<IConfirmationService<AutomatedTransaction>>().Impl...
I've created an ISearchable interface that I've Typed so that I can retrieve an IEnumerable of T for the results.
I have a number of services that implement ISearchable for different domain objects ...
Container.RegisterType<ISearchable<Animal>, AnimalService>();
Container.RegisterType<ISearchable<Fish>, FishService>();
I...
Hi all,
I understand the IOC concept, which we can mix-and-match different classes using wiring.
Every class can get away from hard code it's dependancy by delegating the wiring / relationship handling to base xml (context xml).
Here is my question, why do we use xml? we can simply wire all the components by using java class.
Instead o...
Hi,
Are there any books focused on the current trends of design? like IOC, lously coupled architectures etc.?
I'm not sure if these are pure design patters per say...
(C# preferred but not really a big deal)
...
Hello.
I'm using Structure map and want to inject instance (constructed by container) into controller's property. Instance should be named and stored in http session context container.
In the previous version of my application I've used custom DI framework and it was easy enough to make such things:
public class MyController : Controll...
I am currently trying to get my head round DI and IoC.
Blogs and article are all well and good but I'd like to see some real working source code however I am currently stuck with web forms at work for the time being and most open source projects that I know of that are implementing these kind of development practices seem to be based on ...
Hi I got the code from a book:
public class Container {
Map<String, Object> components;
public Container() {
components = new HashMap<String, Object>();
Properties properties = new Properties();
try {
properties.load(new FileInputStream("components.properties"));
for (Map.Entry entry : properties.en...
I was recently taking a look at the Kazi Manzur Kigg MVC implementation (Kazi rocks) and noticed some code that seemed to defeat the DRY/SOC principle. I'd love to have everyone's thoughts on a possible refactor to separate concerns.
Kigg implements both an Add and Remove method on each repository class ( Note: BaseRepository has virtu...