Created
February 20, 2012 19:08
-
-
Save tawman/1870778 to your computer and use it in GitHub Desktop.
Glimpse Issue 146 Sample Code of Helper used to setup StructureMap for FilterAttribute Injection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web.Mvc; | |
using StructureMap; | |
namespace Sample.Web.Helpers | |
{ | |
public class StructureMapFilterProvider : FilterAttributeFilterProvider | |
{ | |
public StructureMapFilterProvider(IContainer container) | |
{ | |
_container = container; | |
} | |
private IContainer _container; | |
public override IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) | |
{ | |
var filters = base.GetFilters(controllerContext, actionDescriptor).ToList(); | |
foreach (var filter in filters) | |
{ | |
_container.BuildUp(filter.Instance); | |
} | |
return filters; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment