ioc-container

ServiceLocator/IOC in ASP.Net environment

I have a home-grown framework that includes a simple ServiceLocator class implemented using a static Dictionary. It was developed for a WinForms environment and did what I wanted just fine. This proves to be a disaster when using the framework in as ASP.Net framework; the Dictionary, a static variable, is instanciated upon first use and...

Does Autofac have a best practice for *optional* Xml configuration?

Background: I wanted to distribute a library to some other developers (something along the lines of an SDK or toolkit abstracting some internal web services). I'm using Autofac in order to inject different versions of the underlying services, mostly for stubbing. I want to distribute this assembly to a wide range of developers: users ...

Castle Windsor Dependency Injection with Multiple Concrete Implementations

Is there a method for Castle Windsor to inject multiple concrete implementations of a single interface into a constructor? I want to do something like this: class Some { public Some(IService[] services) { services.Each(s => s.DoSomething(this)); } } Note, at this level I do not have access to the IWindsorContainer and ...

How do I wire up Castle Windsor in a Web Forms Web Site Project

I'm trying to introduce dependency injection into an existing Web Forms application. The project was created as a Web Site project (as opposed to a Web Application Project). I have seen samples where you create your global class in global.asax.cs and it looks something like this: public class GlobalApplication : HttpApplication, ICont...

Taking my MVC to the next level: DI and Unit of Work

I have looked at simpler applications like Nerddinner and ContactManager as well as more complicated ones like Kigg. I understand the simpler ones and now I would like to understand the more complex ones. Usually the simpler applications have repository classes and interfaces (as loosely coupled as they can get) on top of either LINQtoS...

Unity (dependency injection): How to pass in a parameter to the constructor in RegisterType

Hi there, Can anyone help? I have a wpf app (shouldn't matter) and in the Onstart i have my bootstrap stuff.. Its like this.. // Create unity container my service and repository container = new UnityContainer() .RegisterType<ISecurityRepository, SecurityRepository>() .RegisterType<ISecurityServi...

Ninject 2.0 Constructor parameter - how to set when default constructor is also present?

I'm new to IOC containers and learning Ninject. I've using version 2.0, freshly downloaded from Github. I'm trying to set a string parameter on a constructor when a default constructor is also present. I've been stepping through the Ninject source but I'm insufficiently familiar with the patterns being used to easily pinpoint what I...

How to modify beans defined in a spring container

I have two xml files defining beans for the springframework (version 2.5.x): containerBase.xml: <beans> <bean id="codebase" class="com.example.CodeBase"> <property name="sourceCodeLocations"> <list> <value>src/handmade/productive</value> </list> </property> </bean> </beans...

Does an abstract class work with StructureMap like an interface does?

I am a big fan of StructureMap and use it in just about everything I do. I have only ever used it with interfaces though. I was wondering if anyone had any experience using with abstract classes? or...does it not support that type of wiring? If you got this to work can you post an example? Thanks! ...

Should I upgrade to Castle Windsor v2?

We are evaluating to upgrade Castle Windsor Container to Version 2, which was released in May this year. By this time I would expect the community to have made some experiences about the new release... My main concerns are: Is it worth the effort to upgrade to v.2? (any major important new functionality or bug fixes?) Is the migration...

IModelBinder or IOC in ASP.NET MVC?

While Scott Hanselman performed an excellent demonstration of the use of IModelBinder in “IPrincipal (User) ModelBinder in ASP.NET MVC for easier testing” he felt compelled to make this rather defensive comment: Yes, I realize I could use an IoC container for this also. Did he mean that he could have used IOC instead of IModelBind...

Autofac with Open Generics and Type Specified at Runtime

The documentation states that Autofac supports open generics and I am able to register and resolve in a basic case like so: Registration: builder.RegisterGeneric(typeof(PassThroughFlattener<>)) .As(typeof(IFlattener<>)) .ContainerScoped(); Resolve: var flattener = _container.Resolve<IFlattener<Address>>(); The above ...

Unity and WCF Library: Where to load unity in a wcf library?

Hi there, can anyone help? I have created a WCF library (not application) and i will be hosting this in a SVC IIS page.. But i was wanting to load the unity stuff in generic place... I could load it in the global.asax but then its tied to the IIS Asp.net container and when doing TDD this part wouldn't execute so not of my resolves wou...

How do I create a well-structured ASP.NET MVC multi-site codebase?

I'm working on a project that has the ultimate vaguely-defined requirement: "Site should be 'skinnable' for other clients." As we all know, there are almost always UI, logic and model changes that have to be made. I've explained that work will be required to add another client to the site, and that it won't be as simple as creating a n...

IoC: Existing runtime objects rather than container-initialised prerequisites for components

In my case I am using Castle Windsor as my IoC container. I would like to declare a component, where one of the constructor arguments will be set to an existing object at runtime, rather than having the IoC container create the object when it creates the component. For example, the instance of my application's main form. I suspect the...

Why is xml so prominently featured in IOC containers?

I'm trying to get into IOC containers, and I notice a large number of them are using xml configuration. Can anyone enlighten me as to why many new technologies are moving towards xml config/programming models (WCF, WPF, Spring.NET, Unity, Windsor)? It seems that xml is a poor choice for specifying complex settings and it would be better ...

overwhelmed by IOC choices

There are so many IOC choices, that I don't know where to begin. I've looked at Spring.NET, Unity, Ninject, Windsor, and StructureMap so far, and I have no idea what makes one better than the other. So, what is your favorite IOC, and what feature(s) makes you use it over any other? ...

DI: Handling Life of IDisposable Objects

So I'm working on my DI/IoC Container OpenNETCF.IoC and I've got a (reasonable) feature request to add some form of lifecycle management for IDisposable items in the container collections. My current thinking is that, since I can't query an object to see if it's been disposed, and I can't get an event for when it's been disposed, that I...

A cluster-aware IoC framework - what would you think it should do?

Hello all, I'm currently trying to pick a thesis topic, preferably using Java. :) There are cases exists, when a full-blown Java EE stack is a bloatware. You don't use many things, you don't need such tight replication, etc. If you choose to go on a lightweight route, you can use Spring, Guice or any other IoC framework, you can use s...

Manage autofac container setup

One of my team members decided to use autofac on one of our services and because we wanted to try it out we stuck with it. Now some time has passed and the container setup method has grown! It so big that we are having problems with it. Splitting it up did not bring the results we looked for. Maybe we are just using it wrong. So my ...