示例#1
0
        protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration)
        {
            foreach (var selector in action.Selectors)
            {
                var httpMethod = selector.ActionConstraints
                                 .OfType <HttpMethodActionConstraint>()
                                 .FirstOrDefault()?
                                 .HttpMethods?
                                 .FirstOrDefault();

                if (httpMethod == null)
                {
                    httpMethod = SelectHttpMethod(action, configuration);
                }

                if (selector.AttributeRouteModel == null)
                {
                    selector.AttributeRouteModel = CreatePlusServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod, configuration);
                }

                if (!selector.ActionConstraints.OfType <HttpMethodActionConstraint>().Any())
                {
                    selector.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { httpMethod }));
                }
            }
        }
示例#2
0
        protected virtual void AddPlusServiceSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration)
        {
            var httpMethod = SelectHttpMethod(action, configuration);

            var PlusServiceSelectorModel = new SelectorModel
            {
                AttributeRouteModel = CreatePlusServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod, configuration),
                ActionConstraints   = { new HttpMethodActionConstraint(new[] { httpMethod }) }
            };

            action.Selectors.Add(PlusServiceSelectorModel);
        }
示例#3
0
 protected virtual string SelectHttpMethod(ActionModel action, ConventionalControllerSetting configuration)
 {
     return(HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName));
 }
示例#4
0
        protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration)
        {
            RemoveEmptySelectors(action.Selectors);

            var remoteServiceAtt = ReflectionHelper.GetSingleAttributeOrDefault <RemoteServiceAttribute>(action.ActionMethod);

            if (remoteServiceAtt != null && !remoteServiceAtt.IsEnabledFor(action.ActionMethod))
            {
                return;
            }

            if (!action.Selectors.Any())
            {
                AddPlusServiceSelector(rootPath, controllerName, action, configuration);
            }
            else
            {
                NormalizeSelectorRoutes(rootPath, controllerName, action, configuration);
            }
        }