Contents tagged with autofac

  • Ioc Comparison: Autoregistration in Autofac

    Autofac is a capable and interesting IoC container. I  looked at Autofac for basic IoC here. Implementing my suite of autoregistration tests in Autofac did not require any custom extension classes, autofac handled everything that I asked of it.

    Autofac adds registrations in an atomic manner, like StructureMap. But Autofac doesn't use lamdbas - you configure a ContainerBuilder in as many steps as needed, and then create a container from this builder in a single operation.

    Continue reading...

  • Comparing .Net IoC containers, part five: Autofac

    I had not used Autofac before this test series, but it used on the Orchard blog engine project and has some interesting advanced features and was quite usable for the basic operations in the tests. The Autofac source code is under the MIT licence is on google code, and is written by Nicholas Blumhardt and other contributors. I have updated this blog post in June 2011 with new code for StructureMap 2, based on the comments by Brendan Forster.

    Autofac requires all types to be registered, and creates a new instance each time by default.

    With Autofac's syntax we are back in the more familiar terain of RegisterType<T>.As<U>(); and Resolve<T>. Note that the RegisterType<T> happens on a ContainerBuilder, and then a container is built from it which can Resolve. Like StructureMap, this emphasises that registration happens before use. The container is not actually immutable (in version 2 onwards), though it doesn't look like changing a container a lot after setup it is encouraged.

    Continue reading...

  • 1