title: Property Injection into an Action Filter
body: <p>I'm trying to get Property Injection working on a Custom Action Filter Attribute. It is working as it is supposed to, however, I'd like to use DI on the Property itself. My filter looks like this</p>
  
  <pre><code>[AttributeUsage(AttributeTargets.Class)]
  public sealed class HeaderFilterAttribute : ActionFilterAttribute
  {
      public IMarketService MarketService
      { get; set; }
  
      public override void OnActionExecuted(ActionExecutedContext filterContext)
      {
          var view = (ViewResultBase)filterContext.Result;
  
          if (view != null)
          {
              BaseViewModel viewModel = view.ViewData.Model as BaseViewModel;
              if (viewModel != null)
                  viewModel.Header = GetHeaderScript();
          }
          base.OnActionExecuted(filterContext);
      }
  
     private string GetHeaderScript()
     {
       //Use MarketService here and return header script
       return "script";
     }
  }
  </code></pre>
  
  <p>This is how I'm configuring the property using StructureMap inside my BootStrapper class.</p>
  
  <pre><code>            //HeaderFilterAttribute
          IMarketRepository marketRepository = new SqlMarketRepository();
          IMarketService marketService = new MarketService(marketRepository);
          ObjectFactory.Container.Configure(r =&gt; r.ForConcreteType&lt;HeaderFilterAttribute&gt;().
                                            Configure.WithProperty("MarketService").
                                            EqualTo(marketService));
  </code></pre>
  
  <p>My problem is I do not have access to SqlMarketRepository since all my concrete types are injected via DI and I really don't want to use concrete types in my bootstrapper. So the ultimate question now is, how do I inject MarketService into the Filter attribute without resorting to the above? :)</p>