private void AddPermissionRecursively(Permission permission)
        {
            //Did defined before?
            Permission existingPermission;
            if (_permissions.TryGetValue(permission.Name, out existingPermission))
            {
                throw new AbpInitializationException("Duplicate permission name detected for " + permission.Name);
            }

            //Add permission
            _permissions[permission.Name] = permission;

            //Add child permissions
            foreach (var childPermission in permission.Children)
            {
                AddPermissionRecursively(childPermission);
            }
        }
示例#2
0
 /// <summary>
 /// Adds a child permission.
 /// A child permission can be granted only if parent is granted.
 /// </summary>
 /// <returns>Returns new child permission</returns>
 public Permission CreateChildPermission(string name, LocalizableString displayName, bool isGrantedByDefault = false, LocalizableString description = null)
 {
     var permission = new Permission(name, displayName, isGrantedByDefault, description) { Parent = this };
     _children.Add(permission);
     return permission;
 }
 /// <summary>
 /// Creates a new permission under this group.
 /// </summary>
 /// <param name="name">Unique name of the permission</param>
 /// <param name="displayName">Display name of the permission</param>
 /// <param name="isGrantedByDefault">Is this permission granted by default. Default value: false.</param>
 /// <param name="description">A brief description for this permission</param>
 /// <returns>New created permission</returns>
 public Permission CreatePermission(string name, LocalizableString displayName, bool isGrantedByDefault = false, LocalizableString description = null)
 {
     var permission = new Permission(name, displayName, isGrantedByDefault, description);
     _permissions.Add(permission);
     return permission;
 }