Example #1
0
        /// <summary>
        /// 配置区域
        /// </summary>
        /// <param name="controller">控制器</param>
        /// <param name="configuration">Controller对应程序集的配置信息</param>
        private void ConfigureArea(ControllerModel controller, [CanBeNull] MSControllerAssemblySetting configuration)
        {
            if (null == configuration)
            {
                return;
            }

            if (controller.RouteValues.ContainsKey("area"))
            {
                return;
            }

            controller.RouteValues["area"] = configuration.ModuleName;
        }
Example #2
0
        private void ConfigureSelector(ControllerModel controller, [CanBeNull] MSControllerAssemblySetting configuration)
        {
            RemoveEmptySelectors(controller.Selectors);
            if (controller.Selectors.Any(selector => selector.AttributeRouteModel != null))
            {
                return;
            }

            var moduleName = GetModuleNameOrDefault(controller.ControllerType.AsType());

            foreach (var action in controller.Actions)
            {
                ConfigureSelector(moduleName, controller.ControllerName, action, configuration);
            }
        }
Example #3
0
 /// <summary>
 /// 配置服务
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="configuration"></param>
 private void ConfigureAppService(ControllerModel controller, [CanBeNull] MSControllerAssemblySetting configuration)
 {
     ConfigureApiExplorer(controller);
     ConfigureSelector(controller, configuration);
     ConfigureParameters(controller);
 }
Example #4
0
        private void AddMSServiceSelector(string moduleName, string controllerName, ActionModel action, [CanBeNull] MSControllerAssemblySetting configuration)
        {
            var msServiceSelectorModel = new SelectorModel {
                AttributeRouteModel = CreateMSServiceAttributeRouteModel(moduleName, controllerName, action)
            };

            var verb = configuration?.UseConventionalHttpVerbs == true
                ? GetConventionalVerbForMethodName(action.ActionName) : "POST";

            msServiceSelectorModel.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { verb }));

            action.Selectors.Add(msServiceSelectorModel);
        }
Example #5
0
        private void ConfigureSelector(string moduleName, string controllerName, ActionModel action, [CanBeNull] MSControllerAssemblySetting configuration)
        {
            RemoveEmptySelectors(action.Selectors);

            //var remoteServiceAtt = ReflectionHelper.GetSingleAttributeOrDefault<RemoteServiceAttribute>(action.ActionMethod);
            //if (remoteServiceAtt != null)
            //{
            //    return;
            //}
            // 可以增加装载过滤器
            // action.Filters.Add()


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