inversion-of-control

What is a .NET proxy object in the Inversion of Control / Aspect-Oriented sense?

What is a proxy object in the Inversion of Control / Aspect-Oriented sense? Any good articles on what a proxy object is ? Why you would want to use one ? And how to write one in C# ? ...

IOC for a Console Application?

Can anyone think of a good solution for getting IOC into a console application? At the moment we are just using a static class with the following method: public static T Resolve<T>() { return dependencyResolver.Resolve<T>(); } I would like the experience to be seamless but cannot think of a way of achieving this from a console ap...

StructureMap : How to define default constructor by code ?

Hi, I can't figure out how to define the default constructor (when it exists overloads) for a type in StructureMap (version 2.5) by code. I want to get an instance of a service and the container has to inject a Linq2Sql data context instance into it. I wrote this in my 'bootstrapper' method : ForRequestedType<MyDataContext>().TheDefa...

How to use Castle Windsor with ASP.Net web forms?

I am trying to wire up dependency injection with Windsor to standard asp.net web forms. I think I have achieved this using a HttpModule and a CustomAttribute (code shown below), although the solution seems a little clunky and was wondering if there is a better supported solution out of the box with Windsor? There are several files all s...

IOC, Mixing injections with parameters in the constructor?

Hi I am new to IOC, so I wanted to know the best strategy to handle the case where I want to pass data structures/paramters as well as injected objects into a class, like simple example: public class EmailSender { public EmailSender(string ToEmail, string Subject,String body, ILogger EmailLogger) {........

IOC Design Resources

I've done quite a bit of searching on this and haven't had much luck finding something cohesive. I'm a relatively new developer and have just started in my first professional development position. I know that I have a great deal to learn even in the realm of the basics. Based on listening to PodCasts, reading blogs, papers etc; I've c...

IoC and User Interfaces

I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue. I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTask for EmployeePresenter) are...

.NET - What IoC Container framework would you recommend to a beginner in this area?

What Inversion of Control Container framework would you recommend to a beginner in this area? ...

Removing or overwriting a component from Windsor Container

I'm trying to accomplish a seemingly super simple thing: from my unit test I want to replace the type being resolved with a mock/fake object. For example: the xml config states that a component of the service IInterface should resolve to ClassA. That's fine, but from my unit test I want the type to resolve to FakeClassA instead. I can't...

Multiple Interface injection with castle windsor

How can you get castle Windsor to choose the right implantation of a interface at run time when you have multiple implementations in the container. For example lets say i have a simple interface called IExamCalc that does calculations to work out how someone did in that exam. No we have several implementation of this like bellow for ex...

Binding to multiple concrete implementations with IOC frameworks?

I'm relatively familiar with the concepts of DI/IOC containers having worked on projects previously where their use were already in place. However, for this new project, there is no existing framework and I'm having to pick one. Long story short, there are some scenarios where we'll be configuring several implementations for a given in...

IoC & Interfaces Best Practices

I'm experimenting with IoC on my way to TDD by fiddling with an existing project. In a nutshell, my question is this: what are the best practices around IoC when public and non-public methods are of interest? There are two classes: public abstract class ThisThingBase { public virtual void Method1() {} public virtual void Method...

Chaining containers with StructureMap

Is it possible to link containers together in StructureMap like it is in WindsorContainer.AddChildContainer()? I want to achieve having 3 container levels; - 1 page request level - 1 session level - 1 application level These would then be chained together so only one instance request would be made to the "base level" container. The le...

Whats ResolveAll do

Hi guys Just a quick one. In IOC's what does ResolveAll do?? I know that the offical answer is "Resolve all valid components that match this type." but does that mean that it will return any class that implements a given interface? Cheers Anthony ...

"List Injection" in Unity?

I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider. I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n implementations of IBacksideP...

How can I dispose every instance object in StructureMap's ObjectFactory?

I'm using StructureMap in my project and when the application finishes running I need to call the Dispose() method on all of the instances inside the ObjectFactory that implement IDisposable. I cannot find anyway to do it via the StructureMap API. Another thought I had was to get a reference to every instance and call it myself, but I ...

generic type dependency injection: How to inject T

I want to handle different types of docs the same way in my application Therefore: I have a generic interface like this. public interface IDocHandler<T>where T: class { T Document { get;set;} void Load(T doc); void Load(string PathToDoc); void Execute(); void Execute(T doc); } And for different types of documents I implement thi...

Castle Windsor - Null constructor argument

How can I pass a null constuctor argument using Castle Windsor? I thought the following would work <parameters> <repository>null</repository> <message>null</message> </parameters> ...

Usage of IoC Containers; specifically Windsor

I think the answer to this question is so obivous that noone has bothered writing about this, but its late and I really can't get my head around this. I've been reading into IoC containers (Windsor in this case) and I'm missing how you talk to the container from the various parts of your code. I get DI, I've been doing poor mans DI (em...

Castle Windsor: How to programatically pass a list parameter to the container?

Is it possible to pass a list constructor parameter when resolving a type? I want to use a programmatic configuration if possible. I've been playing around with the Parameters method as shown below, but I've not yet stumbled upon the answer. container.Register( Component .For<IDoSomething>() .ImplementedBy<DoSomething>() ...