/// <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; }
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); } }
/// <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); }
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); }
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); } }