Beispiel #1
0
        /// <summary>
        /// 配置应用模型信息
        /// </summary>
        /// <param name="application">引用模型</param>
        public void Apply(ApplicationModel application)
        {
            var controllers = application.Controllers.Where(u => Penetrates.IsApiController(u.ControllerType));

            foreach (var controller in controllers)
            {
                var controllerType = controller.ControllerType;

                // 判断是否处理 Mvc控制器
                if (typeof(ControllerBase).IsAssignableFrom(controller.ControllerType))
                {
                    if (!_dynamicApiControllerSettings.SupportedMvcController.Value || controller.ApiExplorer?.IsVisible == false)
                    {
                        // 控制器默认处理规范化结果
                        if (UnifyContext.EnabledUnifyHandler)
                        {
                            foreach (var action in controller.Actions)
                            {
                                // 配置动作方法规范化特性
                                ConfigureActionUnifyResultAttribute(action);
                            }
                        }

                        continue;
                    }
                }

                var controllerApiDescriptionSettings = controllerType.IsDefined(typeof(ApiDescriptionSettingsAttribute), true) ? controllerType.GetCustomAttribute <ApiDescriptionSettingsAttribute>(true) : default;
                ConfigureController(controller, controllerApiDescriptionSettings);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 配置应用模型信息
        /// </summary>
        /// <param name="application">引用模型</param>
        public void Apply(ApplicationModel application)
        {
            var controllers = application.Controllers.Where(u => Penetrates.IsApiController(u.ControllerType));

            foreach (var controller in controllers)
            {
                var controllerType = controller.ControllerType;

                // 判断是否处理 Mvc控制器
                if (typeof(ControllerBase).IsAssignableFrom(controller.ControllerType))
                {
                    if (!_dynamicApiControllerSettings.SupportedMvcController.Value || controller.ApiExplorer?.IsVisible == false)
                    {
                        continue;
                    }
                }

                var controllerApiDescriptionSettings = controllerType.IsDefined(typeof(ApiDescriptionSettingsAttribute), true) ? controllerType.GetCustomAttribute <ApiDescriptionSettingsAttribute>(true) : default;
                ConfigureController(controller, controllerApiDescriptionSettings);
            }
        }
Beispiel #3
0
 /// <summary>
 /// 扫描控制器
 /// </summary>
 /// <param name="typeInfo">类型</param>
 /// <returns>bool</returns>
 protected override bool IsController(TypeInfo typeInfo)
 {
     return(Penetrates.IsApiController(typeInfo));
 }