Files
mixtape/zero.Web/Filters/BackofficeGenericControllerAttribute.cs
T

23 lines
544 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc.ApplicationModels;
using System;
using zero.Core.Extensions;
namespace zero.Web.Filters
{
public class BackofficeGenericControllerAttribute : Attribute, IControllerModelConvention
{
const char BACKTICK = '`';
const string CONTROLLER = "Controller";
public void Apply(ControllerModel controller)
{
if (controller.ControllerName.Contains(BACKTICK))
{
controller.ControllerName = controller.ControllerName.Split(BACKTICK)[0].TrimEnd(CONTROLLER);
}
}
}
}