A while ago, I joined the ranks of those whose favorite new container became Autofac. Why do I like it? it’s FAST, easy to use, and very powerful due to it’s functional nature. You might say I am biased because the guy who wrote it was on my team, but anyway…
If you head over to Google Code, you’ll see a lot of cool stuff coming in version 2. My favorite feature is below, ripped from the wiki. If our new PartCreator<T> was reading this it would be seriously jealous!
When one component needs to dynamically create instances of another, it can take a dependency on a delegate that returns the type of component it requires:
public UsesServer(Func<IServerConnection> connectionFactory)
_connectionFactory = connectionFactory;
public void OnNewWork()
IServerConnection connection = _connectionFactory();
No explicit configuration is required to use this feature:
By registering IServerConnection, Autofac 2 will automatically inject delegates that return type IServerConnection.
If you are gaga over Autofac, go check it out. If not, you should be!