aspnet/Mvc — pull request #1568 by dstarcev (2014-11-16 22:23:43+00:00)
Title: Added support for parametrized DI-friendly action filters.

How to use:
1. Create data-only attribute class inherited from ```ParametrizedFilterAttribute```. Add parameters as non-private properties:
```
public class MyParametrizedFilterAttribute : ParametrizedFilterAttribute
{
public int MyParameter { get; set; }
public int MySecondParameter { get; set; }
}
```

2. Create filter class inherited from ```ParametrizedFilterBase<>```. Inject required services to constructor. Override required methods. Attribute instance will be passed as parameter to each method:
```
public class MyParametrizedFilter : ParametrizedFilterBase
{
private readonly IMyService _service;

public MyParametrizedFilter(IMyService service)
{
_service = service;
}

// all mvc filter methods are supported the same way
public override void OnActionExecuting(
ActionExecutingContext context,
MyParametrizedFilterAttribute data)
{
var myValue = _service.CalculateSomething(
data.MyParameter,
data.MySecondParameter,
GetSomethingFromContext(context));

context.Result = new ContentResult {
Content = myValue.ToString()
};
}
}
```

3. Register filter in IoC container with ```IParametrizedFilter<>``` service:
```
services.AddSingleton, MyParametrizedFilter>();
```

4. Use new attribute as a regular filter with parameters:
```
[MyParametrizedFilterAttribute(MyParameter = 10, MySecondParameter = 435, Order = 1)]
public IActionResult TheAction()
{
}
```