Saturday, March 12, 2011

Unity InjectionFactory

Although Unity 2.0 is out for a while, it took me until now to try some of the nice new features.  One of the nicest feature is the InjectionFactory which replaces the StaticFactoryExtension that was available in Unity 1.2.

A small sample:

using (var container = new UnityContainer())
.RegisterType<IService, ConcreteService>(
new InjectionFactory(c => new ConcreteService()));

var service= container.Resolve<IService>();

1 comment:

Anonymous said...