Ejemplo n.º 1
0
        public FilterInfo GetFilters(FilterRegistryContext context)
        {
            FilterInfo filters = new FilterInfo();

            foreach (FilterRegistryItem item in items)
            {
                if (item.Match(context))
                {
                    object filterObject = container.Resolve(item.FilterType);

                    if (filterObject is IActionFilter)
                    {
                        filters.ActionFilters.Add((IActionFilter)filterObject);
                    }

                    if (filterObject is IAuthorizationFilter)
                    {
                        filters.AuthorizationFilters.Add((IAuthorizationFilter)filterObject);
                    }

                    if (filterObject is IExceptionFilter)
                    {
                        filters.ExceptionFilters.Add((IExceptionFilter)filterObject);
                    }

                    if (filterObject is IResultFilter)
                    {
                        filters.ResultFilters.Add((IResultFilter)filterObject);
                    }
                }
            }

            return(filters);
        }
Ejemplo n.º 2
0
        public bool Match(FilterRegistryContext context)
        {
            ReflectedActionDescriptor reflectedDescriptor = context.ActionDescriptor as ReflectedActionDescriptor;

            if (reflectedDescriptor != null)
            {
                return(methods.Any(a => a.MethodInfo == reflectedDescriptor.MethodInfo));
            }

            return(methods.Any(a => a.ControllerDescriptor.FindAction(context.ControllerContext, context.ActionDescriptor.ActionName) != null));
        }
Ejemplo n.º 3
0
 public bool Match(FilterRegistryContext context)
 {
     return(filterCriteria.Aggregate(true, (prev, f) => prev ? f.Match(context) : prev));
 }
 public bool Match(FilterRegistryContext context)
 {
     return(string.Equals(format, context.ControllerContext.RouteData.Values["dataFormat"] as string, StringComparison.OrdinalIgnoreCase));
 }