Created
February 21, 2017 16:07
-
-
Save joncloud/b017b5efb3fe0fff92d306d8c0f8cda4 to your computer and use it in GitHub Desktop.
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
| class FilterTest | |
| { | |
| public FilterTest(Dictionary<Type, object> parameters) | |
| { | |
| HttpContext httpContext = new DefaultHttpContext(); | |
| RouteData routeData = new RouteData(); | |
| List<ParameterDescriptor> parameterDescriptors = | |
| parameters.Select(pair => new ParameterDescriptor | |
| { | |
| BindingInfo = new BindingInfo | |
| { | |
| BindingSource = BindingSource.Body | |
| }, | |
| Name = pair.Key.Name, | |
| ParameterType = pair.Key | |
| }) | |
| .ToList(); | |
| ActionDescriptor actionDescriptor = new ActionDescriptor | |
| { | |
| Parameters = parameterDescriptors | |
| }; | |
| ActionContext = new ActionContext( | |
| httpContext, | |
| routeData, | |
| actionDescriptor); | |
| Filters = new List<IFilterMetadata>(); | |
| ActionArguments = parameters.ToDictionary(pair => pair.Key.Name, pair => pair.Value); | |
| Controller = new object(); | |
| } | |
| public ActionContext ActionContext { get; } | |
| public IList<IFilterMetadata> Filters { get; } | |
| public IDictionary<string, object> ActionArguments { get; } | |
| public object Controller { get; } | |
| public ActionExecutingContext CreateActionExecutingContext() | |
| => new ActionExecutingContext(ActionContext, Filters, ActionArguments, Controller); | |
| public ActionExecutedContext CreateActionExecutedContext() | |
| => new ActionExecutedContext(ActionContext, Filters, Controller); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment