コード例 #1
0
        /// <summary>
        /// 生成路由
        /// </summary>
        /// <param name="action"></param>
        private void AddApplicationServiceSelector(string areaName, string controllerName, ActionModel action)
        {
            var httpMethod = HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName);

            action.ActionName = GetActualActionName(action.ActionName);
            var selector = new SelectorModel();

            selector.AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(CreateRouter(areaName, controllerName, action)));
            selector.ActionConstraints.Add(new HttpMethodActionConstraint(new [] { httpMethod }));
            action.Selectors.Add(selector);
        }
コード例 #2
0
        private void NormalizeSelectorRoutes(string areaName, string controllerName, ActionModel action)
        {
            action.ActionName = GetActualActionName(action.ActionName);
            var httpMethod = HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName);

            foreach (var selector in action.Selectors)
            {
                if (selector.AttributeRouteModel == null)
                {
                    selector.AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(CreateRouter(areaName, controllerName, action)));
                }
                if (selector.ActionConstraints.OfType <HttpMethodActionConstraint> ().FirstOrDefault()?.HttpMethods?.FirstOrDefault() == null)
                {
                    selector.ActionConstraints.Add(new HttpMethodActionConstraint(new [] { httpMethod }));
                }
            }
        }