Unity is the name of the DI container that is being built for Enterprise Library 4 - yeap, finally Microsoft is getting strong naming for their products, it was born as DIAB, DI Application Block.
Here's a typical usage scenario:
UnityContainer container = new UnityContainer()
.Register<ILogger, TraceLogger>()
.Register<ISomething, Something>()
.Register<ISomethingElse, SomethingElse>();
ILogger logger = container.Get<ILogger>();
logger.Write("log something", new string[] {"category1", "category2"});
A little more verbose version of the factory abstraction, but definitely a clear one. But above all:
It opens up the software factories and Enterprise Library to something other than ObjectBuilder and allow us to use our DI Tool of choice - whether that be the DIAB or another tool.
No comments:
Post a Comment