{"id":972,"date":"2010-01-14T15:06:21","date_gmt":"2010-01-14T14:06:21","guid":{"rendered":"http:\/\/www.gamlor.info\/wordpress\/?p=972"},"modified":"2021-03-11T09:45:22","modified_gmt":"2021-03-11T08:45:22","slug":"autofac-2-x","status":"publish","type":"post","link":"https:\/\/www.gamlor.info\/wordpress\/2010\/01\/autofac-2-x\/","title":{"rendered":"Autofac 2.x"},"content":{"rendered":"<p>A new version of favorite <a href=\"http:\/\/www.martinfowler.com\/articles\/injection.html\">dependency-injection-container<\/a> <a href=\"http:\/\/www.autofac.org\">Autofac<\/a> is making progress. It follows the same principals, brings some new features etc. However they also refactored the API, so it isn\u2019t compatible with the older versions.     <br \/>This means, that migrating to the new version is some work. However there are <a href=\"http:\/\/code.google.com\/p\/autofac\/wiki\/NewInV2\">useful new features<\/a>. <\/p>\n<p>Lots of them I\u2019ve implemented on top of the old Autofac-version:<\/p>\n<ul>\n<li>Collection Support (&quot;Resolve All&quot;): I\u2019ve implemented something like this. Basically it allows you to resolve multiple implementation of a service. Very useful for some simple plugin-mechanisms. (not every application needs <a href=\"http:\/\/www.codeplex.com\/MEF\/\">MEF<\/a>)<\/li>\n<li>Auto-Generated Factories: Allows you to create multiple instances of an service. The container is responsible for implementing a factory. This feature I\u2019ve also implemented. <\/li>\n<li>Owned Instances: Autofac has extremely good support for managing resources. Now you can inject a Owned&lt;T&gt; instance, which creates a new disposable scope. When you call Owed&lt;T&gt;.Dispose(), the service T, with its resources and dependencies are disposed.      <br \/>I\u2019ve implemented something similar: All services exposing the IDisposable-interface create a own scope. As soon as you dispose the service the scope with its resources etc is disposed.<\/li>\n<\/ul>\n<p>Autofac 2.1 already bring support <a href=\"http:\/\/nblumhardt.com\/2009\/12\/lazing-around-with-autofac2\/\">for the .NET 4.0 stuff like Lazy&lt;T&gt; etc<\/a>. <\/p>\n<p>I keep an eye on <a href=\"http:\/\/nblumhardt.com\/\">Nicholas Blumhardt\u2019s blog<\/a> and as soon as Autofac is out of beta, I\u2019ll migrate. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A new version of favorite dependency-injection-container Autofac is making progress. It follows the same principals, brings some new features etc. However they also refactored the API, so it isn\u2019t compatible&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[126],"tags":[21,102,101],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/972"}],"collection":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/comments?post=972"}],"version-history":[{"count":2,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/972\/revisions"}],"predecessor-version":[{"id":3760,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/972\/revisions\/3760"}],"wp:attachment":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/media?parent=972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/categories?post=972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/tags?post=972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}