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), }}
第一個地方由於改進成 spa
使用Enumcode
[Description("Tickets")] public enum Tickets{ [Description("View all ticket")] ViewAll, Edit, Delete, }
第二個改爲反射的方式來獲取全部的寫好的權限。blog