public virtual void ProvideFilter(FilterProviderContext context, FilterItem filterItem) { if (filterItem.Filter != null) { return; } var filter = filterItem.Descriptor.Filter; var filterFactory = filter as IFilterFactory; if (filterFactory == null) { filterItem.Filter = filter; } else { var services = context.ActionContext.HttpContext.RequestServices; filterItem.Filter = filterFactory.CreateInstance(services); if (filterItem.Filter == null) { throw new InvalidOperationException(Resources.FormatTypeMethodMustReturnNotNullValue( "CreateInstance", typeof(IFilterFactory).Name)); } ApplyFilterToContainer(filterItem.Filter, filterFactory); } }
public virtual void ProvideFilter(FilterProviderContext context, FilterItem filterItem) { if (filterItem.Filter != null) { return; } var filter = filterItem.Descriptor.Filter; var filterFactory = filter as IFilterFactory; if (filterFactory == null) { filterItem.Filter = filter; } else { var services = context.ActionContext.HttpContext.RequestServices; filterItem.Filter = filterFactory.CreateInstance(services); if (filterItem.Filter == null) { throw new InvalidOperationException(Resources.FormatTypeMethodMustReturnNotNullValue( "CreateInstance", typeof(IFilterFactory).Name)); } ApplyFilterToContainer(filterItem.Filter, filterFactory); } }
public static bool ContainsMatch(this List<AreaNode> routeTree, FilterProviderContext context) { ControllerActionDescriptor cad = (ControllerActionDescriptor)context.ActionContext.ActionDescriptor; string area = (string)context.ActionContext.RouteData.Values["area"]; var areaNode = routeTree.Find(x => { if (string.IsNullOrEmpty(x.Area) && string.IsNullOrEmpty(area)) return true; return String.Compare(area, x.Area, StringComparison.OrdinalIgnoreCase) == 0; }); if (areaNode != null) { if (areaNode.Controllers == null || !areaNode.Controllers.Any()) return true; var controllerNode = areaNode.Controllers.Find(x => String.Compare(cad.ControllerName, x.Controller, StringComparison.OrdinalIgnoreCase) == 0); if (controllerNode != null) { if (controllerNode.Actions == null || !controllerNode.Actions.Any()) return true; var action = controllerNode.Actions.Find(x => String.Compare(cad.Name, x.Action, StringComparison.OrdinalIgnoreCase) == 0); return action != null; } } return false; }
/// <inheritdoc /> public void OnProvidersExecuting([NotNull] FilterProviderContext context) { if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) { foreach (var item in context.Results) { ProvideFilter(context, item); } } }
/// <inheritdoc /> public void OnProvidersExecuting([NotNull] FilterProviderContext context) { if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) { // Perf: Avoid allocations for (var i = 0; i < context.Results.Count; i++) { ProvideFilter(context, context.Results[i]); } } }
/// <inheritdoc /> public void OnProvidersExecuting(FilterProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) { // Perf: Avoid allocations for (var i = 0; i < context.Results.Count; i++) { ProvideFilter(context, context.Results[i]); } } }
/// <inheritdoc /> public void OnProvidersExecuting(FilterProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) { // Perf: Avoid allocations for (var i = 0; i < context.Results.Count; i++) { ProvideFilter(context, context.Results[i]); } } }
/// <inheritdoc /> public void OnProvidersExecuting(FilterProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var services = context.ActionContext.HttpContext.RequestServices; var filters = services.GetService<IEnumerable<IFilterMetadata>>(); if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) { foreach (var filter in filters) { var filterItem = new FilterItem(new FilterDescriptor(filter, FilterScope.Global), filter); context.Results.Add(filterItem); } } }
/// <inheritdoc /> public void OnProvidersExecuted([NotNull] FilterProviderContext context) { }
/// <inheritdoc /> public void OnProvidersExecuted(FilterProviderContext context) { }
/// <inheritdoc /> public void OnProvidersExecuted(FilterProviderContext context) { }