public class StructureMapFilterProvider : FilterAttributeFilterProvider
{
/// <summary>
/// Structuremap instance.
/// </summary>
private readonly IContainer container;
/// <summary>
/// Initializes a new instance of the <see cref="StructureMapFilterProvider"/> class.
/// </summary>
/// <param name="container">The container.</param>
public StructureMapFilterProvider(IContainer container)
{
this.container = container;
}
/// <summary>
/// Intercept's GetFilters, then use the "BuildUp" feature of structuremap to avoid using decorators for property injection and this
/// involves coupling.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>A list of filters for the current context.</returns>
public override IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
var filters = base.GetFilters(controllerContext, actionDescriptor);
if (filters != null)
{
foreach (var filter in filters)
{
this.container.BuildUp(filter.Instance);
}
return filters;
}
return default(IEnumerable<Filter>);
}
}
Neat, I like it!
Friday, November 11, 2011
Code formatter for blogs
I came across this site that allows for easy formatting of source code for displaying on blog posts. Pretty cool. This is a test post...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment