public static class Tickets { public const string GroupName = "Tickets"; public const string CreateTicket = "tickets:ticket:create"; public const string NameOfCreateTicket = "Create ticket"; public const string EditTicket = "users:user:edit"; public const string NameOfEditTicket = "Edit ticket"; public const string DeleteTicket = "tickets:ticket:delete"; public const string NameOfDeleteTicket = "Delete ticket"; } public GetPermissions(){ return new List<PredefinedPermission>(){ new PredefinedPermission(Tickets.ViewAllTickets,Tickets.NameOfViewTickets,Tickets.GroupName), new PredefinedPermission(Tickets.CreateTicket,Tickets.NameOfCreateTicket,Tickets.GroupName), new PredefinedPermission(Tickets.EditTicket,Tickets.NameOfEditTicket,Tickets.GroupName), new PredefinedPermission(Tickets.DeleteTicket,Tickets.NameOfViewTickets,Tickets.GroupName), }}
第一个地方因为改进成
使用Enum
[Description("Tickets")] public enum Tickets{ [Description("View all ticket")] ViewAll, Edit, Delete, }
第二个改成反射的方式来获取所有的写好的权限。