title: DI: Injecting ActionFilterAttribute implementation (ASP.NET MVC)
body: <p>I was wondering if it is possible to inject a particular <code>ActionFilterAttribute</code> implementation using a IoC container.</p>
  
  <p>For example, imagine you create a <code>TransactionAttribute</code> class <code>[Transaction]</code></p>
  
  <p>You use this to decorate action which should be wrapped in a transaction in the persistence layer.  But implementation details of the attribute will be tied to the persistence tech you are using, and strictly speaking, your controller should not know about this, and you might want to swap this out.</p>
  
  <p>What I would like to do, is define some kind of <code>TransactionAttribute</code> interface, and then have my IoC container inject the correct implementation.  So on my actions I only need specify:</p>
  
  <pre><code> [Transaction]
   public ActionResult SomeAction()
   {
       ....
   }
  </code></pre>
  
  <p>...and the IoC will inject the correct implementation depending on config (eg. something like <code>NHibernateTransactionAttribute</code>, or <code>SomeOtherORMTransactionAttribute</code>).</p>
  
  <p>Is this possible? Has anyone done it?</p>