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 })); } } }
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); }
protected virtual string SelectHttpMethod(ActionModel action, ConventionalControllerSetting configuration) { return(HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName)); }
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); } }