Ejemplo n.º 1
0
        /// <summary>
        /// 配置控制器
        /// </summary>
        /// <param name="controller">控制器模型</param>
        /// <param name="apiDescriptionSettingsAttribute">接口描述配置</param>
        private void ConfigureController(ControllerModel controller, ApiDescriptionSettingsAttribute apiDescriptionSettings)
        {
            // 配置控制器名称
            ConfigureControllerName(controller, apiDescriptionSettings);

            var actions = controller.Actions;

            foreach (var action in actions)
            {
                var actionApiDescriptionSettings = action.Attributes.FirstOrDefault(u => u is ApiDescriptionSettingsAttribute) as ApiDescriptionSettingsAttribute;
                ConfigureAction(action, actionApiDescriptionSettings, apiDescriptionSettings);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 配置动作方法名称
 /// </summary>
 /// <param name="action">动作方法模型</param>
 /// <param name="apiDescriptionSettings">接口配置描述</param>
 private void ConfigureActionName(ActionModel action, ApiDescriptionSettingsAttribute apiDescriptionSettings)
 {
     action.ActionName = ConfigureControllerAndActionName(apiDescriptionSettings, action.ActionName, _lazyControllerSettings.AbandonActionAffixes, (tempName) =>
     {
         // 处理动作方法名称谓词
         if (apiDescriptionSettings?.KeepVerb != true)
         {
             var words   = Penetrates.SplitCamelCase(tempName);
             var verbKey = words.First().ToLower();
             // 处理类似 getlist,getall 多个单词
             if (words.Length > 1 && Penetrates.VerbToHttpMethods.ContainsKey((words[0] + words[1]).ToLower()))
             {
                 tempName = tempName[(words[0] + words[1]).Length..];
             }
Ejemplo n.º 3
0
        private void ConfigureAction(ActionModel action, ApiDescriptionSettingsAttribute apiDescriptionSettings, ApiDescriptionSettingsAttribute controllerApiDescriptionSettings)
        {
            // 配置动作方法接口可见性
            ConfigureActionApiExplorer(action);

            // 配置动作方法名称
            ConfigureActionName(action, apiDescriptionSettings);

            // 配置动作方法请求谓词特性
            ConfigureActionHttpMethodAttribute(action);

            // 配置引用类型参数
            ConfigureClassTypeParameter(action);

            // 配置动作方法路由特性
            ConfigureActionRouteAttribute(action, apiDescriptionSettings, controllerApiDescriptionSettings);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 配置控制器名称
 /// </summary>
 /// <param name="controller">控制器模型</param>
 /// <param name="apiDescriptionSettings">接口描述配置</param>
 private void ConfigureControllerName(ControllerModel controller, ApiDescriptionSettingsAttribute apiDescriptionSettings)
 {
     controller.ControllerName = ConfigureControllerAndActionName(apiDescriptionSettings, controller.ControllerName, _lazyControllerSettings.AbandonControllerAffixes, _ => _);
 }