|
|
@ -14,13 +14,13 @@ using Volo.Abp.Http; |
|
|
using Volo.Abp.Http.Modeling; |
|
|
using Volo.Abp.Http.Modeling; |
|
|
using Volo.Abp.Reflection; |
|
|
using Volo.Abp.Reflection; |
|
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Mvc |
|
|
namespace Volo.Abp.AspNetCore.Mvc.Conventions |
|
|
{ |
|
|
{ |
|
|
public class AbpAppServiceConvention : IAbpAppServiceConvention, ITransientDependency |
|
|
public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency |
|
|
{ |
|
|
{ |
|
|
private readonly AbpAspNetCoreMvcOptions _options; |
|
|
private readonly AbpAspNetCoreMvcOptions _options; |
|
|
|
|
|
|
|
|
public AbpAppServiceConvention(IOptions<AbpAspNetCoreMvcOptions> options) |
|
|
public AbpServiceConvention(IOptions<AbpAspNetCoreMvcOptions> options) |
|
|
{ |
|
|
{ |
|
|
_options = options.Value; |
|
|
_options = options.Value; |
|
|
} |
|
|
} |
|
|
@ -38,8 +38,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
var configuration = GetControllerSettingOrNull(controllerType); |
|
|
var configuration = GetControllerSettingOrNull(controllerType); |
|
|
|
|
|
|
|
|
//TODO: We can remove different behaviour for ImplementsRemoteServiceInterface. If there is a configuration, then it should be applied!
|
|
|
//TODO: We can remove different behaviour for ImplementsRemoteServiceInterface. If there is a configuration, then it should be applied!
|
|
|
//TODO: If so, we can rename AppServiceControllers to ConventionalControllers!
|
|
|
//TODO: But also consider ConventionalControllerSetting.IsRemoteService method too..!
|
|
|
//TODO: But also consider AbpControllerAssemblySetting.IsRemoteService method too..!
|
|
|
|
|
|
|
|
|
|
|
|
if (ImplementsRemoteServiceInterface(controllerType)) |
|
|
if (ImplementsRemoteServiceInterface(controllerType)) |
|
|
{ |
|
|
{ |
|
|
@ -58,7 +57,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void ConfigureRemoteService(ControllerModel controller, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual void ConfigureRemoteService(ControllerModel controller, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
ConfigureApiExplorer(controller); |
|
|
ConfigureApiExplorer(controller); |
|
|
ConfigureSelector(controller, configuration); |
|
|
ConfigureSelector(controller, configuration); |
|
|
@ -95,7 +94,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
|
|
|
|
|
|
protected virtual bool CanUseFormBodyBinding(ActionModel action, ParameterModel parameter) |
|
|
protected virtual bool CanUseFormBodyBinding(ActionModel action, ParameterModel parameter) |
|
|
{ |
|
|
{ |
|
|
if (_options.AppServiceControllers.FormBodyBindingIgnoredTypes.Any(t => t.IsAssignableFrom(parameter.ParameterInfo.ParameterType))) |
|
|
if (_options.ConventionalControllers.FormBodyBindingIgnoredTypes.Any(t => t.IsAssignableFrom(parameter.ParameterInfo.ParameterType))) |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
@ -168,7 +167,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void ConfigureSelector(ControllerModel controller, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual void ConfigureSelector(ControllerModel controller, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
RemoveEmptySelectors(controller.Selectors); |
|
|
RemoveEmptySelectors(controller.Selectors); |
|
|
|
|
|
|
|
|
@ -185,7 +184,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
RemoveEmptySelectors(action.Selectors); |
|
|
RemoveEmptySelectors(action.Selectors); |
|
|
|
|
|
|
|
|
@ -199,7 +198,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void AddAbpServiceSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual void AddAbpServiceSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
var httpMethod = SelectHttpMethod(action, configuration); |
|
|
var httpMethod = SelectHttpMethod(action, configuration); |
|
|
|
|
|
|
|
|
@ -212,12 +211,12 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
action.Selectors.Add(abpServiceSelectorModel); |
|
|
action.Selectors.Add(abpServiceSelectorModel); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual string SelectHttpMethod(ActionModel action, AbpControllerAssemblySetting configuration) |
|
|
protected virtual string SelectHttpMethod(ActionModel action, ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
return HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName); |
|
|
return HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
foreach (var selector in action.Selectors) |
|
|
foreach (var selector in action.Selectors) |
|
|
{ |
|
|
{ |
|
|
@ -236,12 +235,12 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[CanBeNull] |
|
|
[CanBeNull] |
|
|
protected virtual AbpControllerAssemblySetting GetControllerSettingOrNull(Type controllerType) |
|
|
protected virtual ConventionalControllerSetting GetControllerSettingOrNull(Type controllerType) |
|
|
{ |
|
|
{ |
|
|
return _options.AppServiceControllers.ControllerAssemblySettings.GetSettingOrNull(controllerType); |
|
|
return _options.ConventionalControllers.ConventionalControllerSettings.GetSettingOrNull(controllerType); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
return new AttributeRouteModel( |
|
|
return new AttributeRouteModel( |
|
|
new RouteAttribute( |
|
|
new RouteAttribute( |
|
|
@ -250,7 +249,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual string CalculateRouteTemplate(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual string CalculateRouteTemplate(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
var controllerNameInUrl = NormalizeUrlControllerName(rootPath, controllerName, action, httpMethod, configuration); |
|
|
var controllerNameInUrl = NormalizeUrlControllerName(rootPath, controllerName, action, httpMethod, configuration); |
|
|
|
|
|
|
|
|
@ -279,7 +278,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
return url; |
|
|
return url; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual string NormalizeUrlActionName(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual string NormalizeUrlActionName(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
var actionNameInUrl = HttpMethodHelper |
|
|
var actionNameInUrl = HttpMethodHelper |
|
|
.RemoveHttpMethodPrefix(action.ActionName, httpMethod) |
|
|
.RemoveHttpMethodPrefix(action.ActionName, httpMethod) |
|
|
@ -301,7 +300,7 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual string NormalizeUrlControllerName(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] AbpControllerAssemblySetting configuration) |
|
|
protected virtual string NormalizeUrlControllerName(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) |
|
|
{ |
|
|
{ |
|
|
if(configuration?.UrlControllerNameNormalizer == null) |
|
|
if(configuration?.UrlControllerNameNormalizer == null) |
|
|
{ |
|
|
{ |