Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static List<ModuleModel> ParsePermissions(Type permissionType)
- {
- var modules = permissionType
- .GetNestedTypes()
- .Where(c => c.GetCustomAttribute<ModuleDescriptionAttribute>() != null)
- .Select(c => new ModuleModel
- {
- Name = c.Name,
- Description = c.GetCustomAttribute<ModuleDescriptionAttribute>(),
- Permissions = c
- .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
- .Where(c => c.FieldType == typeof(string))
- .ToDictionary(c => c.Name, c => new PermissionModel
- {
- Name = c.Name,
- Value = c.GetValue(null)?.ToString(),
- Description = c.GetCustomAttribute<PermissionDescriptionAttribute>()
- })
- }).ToList();
- return modules;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement