mirror of https://github.com/abpframework/abp.git
committed by
GitHub
14 changed files with 118 additions and 82 deletions
Binary file not shown.
@ -1,26 +1,36 @@ |
|||||
using System; |
using System; |
||||
using System.Reflection; |
using System.Reflection; |
||||
|
using JetBrains.Annotations; |
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels; |
using Microsoft.AspNetCore.Mvc.ApplicationModels; |
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc |
namespace Volo.Abp.AspNetCore.Mvc |
||||
{ |
{ |
||||
public class AbpControllerAssemblySetting |
public class AbpControllerAssemblySetting |
||||
{ |
{ |
||||
|
[NotNull] |
||||
public Assembly Assembly { get; } |
public Assembly Assembly { get; } |
||||
|
|
||||
|
[NotNull] |
||||
public string RootPath { get; } |
public string RootPath { get; } |
||||
|
|
||||
|
[CanBeNull] |
||||
public Func<Type, bool> TypePredicate { get; set; } |
public Func<Type, bool> TypePredicate { get; set; } |
||||
|
|
||||
|
[CanBeNull] |
||||
public Action<ControllerModel> ControllerModelConfigurer { get; set; } |
public Action<ControllerModel> ControllerModelConfigurer { get; set; } |
||||
|
|
||||
public AbpControllerAssemblySetting(Assembly assembly, string rootPath) |
[CanBeNull] |
||||
|
public Func<UrlControllerNameNormalizerContext, string> UrlControllerNameNormalizer { get; set; } |
||||
|
|
||||
|
[CanBeNull] |
||||
|
public Func<UrlActionNameNormalizerContext, string> UrlActionNameNormalizer { get; set; } |
||||
|
|
||||
|
public AbpControllerAssemblySetting([NotNull] Assembly assembly, [NotNull] string rootPath) |
||||
{ |
{ |
||||
|
Check.NotNull(assembly, rootPath); |
||||
|
|
||||
Assembly = assembly; |
Assembly = assembly; |
||||
RootPath = rootPath; |
RootPath = rootPath; |
||||
|
|
||||
TypePredicate = type => true; |
|
||||
ControllerModelConfigurer = controller => { }; |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,20 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Http; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc |
|
||||
{ |
|
||||
public class DefaultUrlActionNameNormalizer : IUrlActionNameNormalizer |
|
||||
{ |
|
||||
public void Normalize(UrlActionNameNormalizerContext context) |
|
||||
{ |
|
||||
if (context.ActionNameInUrl.IsNullOrEmpty()) |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
context.ActionNameInUrl = HttpMethodHelper |
|
||||
.RemoveHttpMethodPrefix(context.ActionNameInUrl, context.HttpMethod) |
|
||||
.RemovePostFix("Async"); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,7 +0,0 @@ |
|||||
namespace Volo.Abp.AspNetCore.Mvc |
|
||||
{ |
|
||||
public interface IUrlActionNameNormalizer |
|
||||
{ |
|
||||
void Normalize(UrlActionNameNormalizerContext context); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,24 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc.ApplicationModels; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc |
||||
|
{ |
||||
|
//TODO: Re-consider properties of this class.
|
||||
|
public class UrlControllerNameNormalizerContext |
||||
|
{ |
||||
|
public string RootPath { get; } |
||||
|
|
||||
|
public string ControllerName { get; } |
||||
|
|
||||
|
public ActionModel Action { get; } |
||||
|
|
||||
|
public string HttpMethod { get; } |
||||
|
|
||||
|
public UrlControllerNameNormalizerContext(string rootPath, string controllerName, ActionModel action, string httpMethod) |
||||
|
{ |
||||
|
RootPath = rootPath; |
||||
|
ControllerName = controllerName; |
||||
|
Action = action; |
||||
|
HttpMethod = httpMethod; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,17 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.AspNetCore.Mvc; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.App |
|
||||
{ |
|
||||
public class PhoneBookUrlActionNameNormalizer : IUrlActionNameNormalizer |
|
||||
{ |
|
||||
public void Normalize(UrlActionNameNormalizerContext context) |
|
||||
{ |
|
||||
if (string.Equals(context.ActionNameInUrl, "phone", StringComparison.OrdinalIgnoreCase)) |
|
||||
{ |
|
||||
context.ActionNameInUrl = "phones"; |
|
||||
return; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue