Thursday
Jan102008
Some more insight into the autofac
Here are some updates:
The code required to compile autofac against .NET 2.0 (in a single file) could be located here.
As Nicholas pointed out, there is no need to register parent scope or do something exceptional about the lambda expression. The expression already evaluates against the current scope. This nicely deals with the previous Castle MicroKernel problem described here (what's more important, it is easy to understand what and why happens behind the curtains). See his snippet below:
ContainerBuilder cb = new ContainerBuilder();
cb.Register(c =>; new A(c.Resolve<B>())).
WithScope(InstanceScope.Factory);
Container parent = cb.Build();
Container child = cb.CreateInnerContainer();
var childBuilder = new ContainerBuilder();
childBuilder.Register(c => new B());
childBuilder.Build(child);
A a = child.Resolve<A>();
More updates are to come. I'll try to check out the following areas of the autofac IoC:
- XML configuration (nothing exceptional is expected, but still you never know)
- Lifestyles and scopes
- Possibility of implementing the policy injection with the autofac (may be lambdas would aid a little bit here too...). It is always nice to know if you can route all your business objects through some fast IoC.
Thursday, January 10, 2008 at 15:30
Reader Comments (1)
[...] « How to use .NET 3.5 syntax and compiler features for .NET 2.0? Some more insight into the autofac [...]