public ControllerlessDescriptor(Type actionType, Object action, IActionMethodSelector methodSelector)
        {
            this.actionType     = actionType;
            this.action         = action;
            this.methodSelector = methodSelector;

            methodDescriptors = methodSelector.GetMethods(this);
        }
        public ControllerlessDescriptor(Type actionType, Object action, IActionMethodSelector methodSelector)
        {
            this.actionType = actionType;
            this.action = action;
            this.methodSelector = methodSelector;

            methodDescriptors = methodSelector.GetMethods(this);
        }
示例#3
0
            private static List <ReflectedHttpActionDescriptor> RunSelectionFilters(HttpControllerContext controllerContext, List <ReflectedHttpActionDescriptor> descriptorsFound)
            {
                // remove all methods which are opting out of this request
                // to opt out, at least one attribute defined on the method must return false

                List <ReflectedHttpActionDescriptor> matchesWithSelectionAttributes    = null;
                List <ReflectedHttpActionDescriptor> matchesWithoutSelectionAttributes = new List <ReflectedHttpActionDescriptor>();

                for (int i = 0; i < descriptorsFound.Count; i++)
                {
                    ReflectedHttpActionDescriptor actionDescriptor = descriptorsFound[i];
                    IActionMethodSelector[]       attrs            = actionDescriptor.CacheAttrsIActionMethodSelector;
                    if (attrs.Length == 0)
                    {
                        matchesWithoutSelectionAttributes.Add(actionDescriptor);
                    }
                    else
                    {
                        bool match = true;
                        for (int j = 0; j < attrs.Length; j++)
                        {
                            IActionMethodSelector selector = attrs[j];
                            if (!selector.IsValidForRequest(controllerContext, actionDescriptor.MethodInfo))
                            {
                                match = false;
                                break;
                            }
                        }
                        if (match)
                        {
                            if (matchesWithSelectionAttributes == null)
                            {
                                matchesWithSelectionAttributes = new List <ReflectedHttpActionDescriptor>();
                            }
                            matchesWithSelectionAttributes.Add(actionDescriptor);
                        }
                    }
                }

                // if a matching action method had a selection attribute, consider it more specific than a matching action method
                // without a selection attribute
                if ((matchesWithSelectionAttributes != null) && (matchesWithSelectionAttributes.Count > 0))
                {
                    return(matchesWithSelectionAttributes);
                }
                else
                {
                    return(matchesWithoutSelectionAttributes);
                }
            }
 public DlrControllerDescriptor(IDlrContext context, IActionMethodSelector selector)
 {
     this.context = context;
     this.selector = selector;
 }
 /// <summary>
 /// 设置默认的操作方法选择器
 /// </summary>
 /// <param name="selector"></param>
 public static void SetActionSelector(IActionMethodSelector selector)
 {
     _ActionSelector = selector;
 }
 /// <summary>
 /// 设置默认的操作方法选择器
 /// </summary>
 /// <param name="selector"></param>
 public static void SetActionSelector(IActionMethodSelector selector)
 {
     _ActionSelector = selector;
 }