/// <summary> /// Clears all the roles in the roles list. This is only meant to be used during the static RefreshAllRoles method. /// </summary> private void ClearRoles() { lock (instanceLockObj) { RolesWithRight.Clear(); } }
/// <summary> /// Removes a Role from the collection of roles that allow this Right. /// </summary> /// <param name="roleName"></param> /// <returns>Returns true if the role was removed, false otherwise.</returns> /// <remarks> /// /// Use this method specifically to remove roles from the internal list. This lets us keep track /// of what's removed from it. /// /// </remarks> public bool RemoveRole(string roleName) { roleName = PrepareRoleName(roleName); if (roleName.Equals(BlogConfig.AdministratorRole, StringComparison.OrdinalIgnoreCase)) { throw new System.Security.SecurityException("Rights can not be removed from the administrative role"); } else { lock (instanceLockObj) { return(RolesWithRight.Remove(roleName)); } } }
/// <summary> /// Adds a role to the list of roles that have this Right. /// </summary> /// <param name="roleName"></param> /// <returns>True if the role doesn't already exist in the list of roles. Otherwise, false.</returns> /// <remarks> /// /// Use this method specifically to add roles to the internal list. This lets us keep track /// of what's added to it. /// /// </remarks> public bool AddRole(string roleName) { roleName = PrepareRoleName(roleName); lock (instanceLockObj) { if (!Roles.Contains(roleName, StringComparer.OrdinalIgnoreCase)) { RolesWithRight.Add(roleName); return(true); } else { return(false); } } }