19 lines
600 B
C#
19 lines
600 B
C#
namespace ASC.Api.Core.Convention;
|
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class ControllerNameAttribute : Attribute
|
|
{
|
|
public string Name { get; }
|
|
|
|
public ControllerNameAttribute(string name) => Name = name;
|
|
}
|
|
|
|
public class ControllerNameAttributeConvention : IControllerModelConvention
|
|
{
|
|
public void Apply(ControllerModel controller)
|
|
{
|
|
var controllerNameAttribute = controller.Attributes.OfType<ControllerNameAttribute>().SingleOrDefault();
|
|
if (controllerNameAttribute != null)
|
|
controller.ControllerName = controllerNameAttribute.Name;
|
|
}
|
|
} |