using System; using System.Linq; using Microsoft.AspNetCore.Mvc.ApplicationModels; 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().SingleOrDefault(); if (controllerNameAttribute != null) { controller.ControllerName = controllerNameAttribute.Name; } } } }