最佳答案
在我的应用程序中,我有一个非常大的权限集,我用一个 Flags 枚举来表示它。它正在迅速接近长数据类型的实际上限。我不得不想出一个策略,尽快过渡到一个不同的结构。现在,我可以把这个列表分成更小的部分,但是,这已经只是我们的应用程序的总体权限的一个子集,基于我们的应用程序布局。在管理权限时,我们广泛地使用这种区别来显示权限,如果可以避免的话,我不希望在这个时候重新访问该代码。
还有其他人遇到这个问题吗?你是怎么熬过来的?一般的例子很好,但是我最感兴趣的是一个 c # 特定的例子,如果有任何语言特定的技巧,我可以使用它来完成工作。
可能没有必要,但是这里是当前为我正在处理的应用程序部分定义的权限列表。
//Subgroup WebAgent
[Flags]
public enum WebAgentPermission : long
{
[DescriptionAttribute("View Rule Group")]
ViewRuleGroup = 1,
[DescriptionAttribute("Add Rule Group")]
AddRuleGroup = 2,
[DescriptionAttribute("Edit Rule Group")]
EditRuleGroup = 4,
[DescriptionAttribute("Delete Rule Group")]
DeleteRuleGroup = 8,
[DescriptionAttribute("View Rule")]
ViewRule = 16,
[DescriptionAttribute("Add Rule")]
AddRule = 32,
[DescriptionAttribute("Edit Rule")]
EditRule = 64,
[DescriptionAttribute("Delete Rule")]
DeleteRule = 128,
[DescriptionAttribute("View Location")]
ViewLocation = 256,
[DescriptionAttribute("Add Location")]
AddLocation = 512,
[DescriptionAttribute("Edit Location")]
EditLocation = 1024,
[DescriptionAttribute("Delete Location")]
DeleteLocation = 2048,
[DescriptionAttribute("View Volume Statistics")]
ViewVolumeStatistics = 4096,
[DescriptionAttribute("Edit Volume Statistics")]
EditVolumeStatistics = 8192,
[DescriptionAttribute("Upload Volume Statistics")]
UploadVolumeStatistics = 16384,
[DescriptionAttribute("View Role")]
ViewRole = 32768,
[DescriptionAttribute("Add Role")]
AddRole = 65536,
[DescriptionAttribute("Edit Role")]
EditRole = 131072,
[DescriptionAttribute("Delete Role")]
DeleteRole = 262144,
[DescriptionAttribute("View User")]
ViewUser = 524288,
[DescriptionAttribute("Add User")]
AddUser = 1048576,
[DescriptionAttribute("Edit User")]
EditUser = 2097152,
[DescriptionAttribute("Delete User")]
DeleteUser = 4194304,
[DescriptionAttribute("Assign Permissions To User")]
AssignPermissionsToUser = 8388608,
[DescriptionAttribute("Change User Password")]
ChangeUserPassword = 16777216,
[DescriptionAttribute("View Audit Logs")]
ViewAuditLogs = 33554432,
[DescriptionAttribute("View Team")]
ViewTeam = 67108864,
[DescriptionAttribute("Add Team")]
AddTeam = 134217728,
[DescriptionAttribute("Edit Team")]
EditTeam = 268435456,
[DescriptionAttribute("Delete Team")]
DeleteTeam = 536870912,
[DescriptionAttribute("View Web Agent Reports")]
ViewWebAgentReports = 1073741824,
[DescriptionAttribute("View All Locations")]
ViewAllLocations = 2147483648,
[DescriptionAttribute("Access to My Search")]
AccessToMySearch = 4294967296,
[DescriptionAttribute("Access to Pespective Search")]
AccessToPespectiveSearch = 8589934592,
[DescriptionAttribute("Add Pespective Search")]
AddPespectiveSearch = 17179869184,
[DescriptionAttribute("Edit Pespective Search")]
EditPespectiveSearch = 34359738368,
[DescriptionAttribute("Delete Pespective Search")]
DeletePespectiveSearch = 68719476736,
[DescriptionAttribute("Access to Search")]
AccessToSearch = 137438953472,
[DescriptionAttribute("View Form Roles")]
ViewFormRole = 274877906944,
[DescriptionAttribute("Add / Edit Form Roles")]
AddFormRole = 549755813888,
[DescriptionAttribute("Delete UserFormRolesDifferenceMasks")]
DeleteFormRole = 1099511627776,
[DescriptionAttribute("Export Locations")]
ExportLocations = 2199023255552,
[DescriptionAttribute("Import Locations")]
ImportLocations = 4398046511104,
[DescriptionAttribute("Manage Location Levels")]
ManageLocationLevels = 8796093022208,
[DescriptionAttribute("View Job Title")]
ViewJobTitle = 17592186044416,
[DescriptionAttribute("Add Job Title")]
AddJobTitle = 35184372088832,
[DescriptionAttribute("Edit Job Title")]
EditJobTitle = 70368744177664,
[DescriptionAttribute("Delete Job Title")]
DeleteJobTitle = 140737488355328,
[DescriptionAttribute("View Dictionary Manager")]
ViewDictionaryManager = 281474976710656,
[DescriptionAttribute("Add Dictionary Manager")]
AddDictionaryManager = 562949953421312,
[DescriptionAttribute("Edit Dictionary Manager")]
EditDictionaryManager = 1125899906842624,
[DescriptionAttribute("Delete Dictionary Manager")]
DeleteDictionaryManager = 2251799813685248,
[DescriptionAttribute("View Choice Manager")]
ViewChoiceManager = 4503599627370496,
[DescriptionAttribute("Add Choice Manager")]
AddChoiceManager = 9007199254740992,
[DescriptionAttribute("Edit Chioce Manager")]
EditChoiceManager = 18014398509481984,
[DescriptionAttribute("Delete Choice Manager")]
DeleteChoiceManager = 36028797018963968,
[DescriptionAttribute("Import Export Choices")] //57
ImportExportChoices = 72057594037927936
}