2using System.Collections.Generic;
3using System.Threading.Tasks;
15 private static readonly Dictionary<string, Privilege> privileges =
new Dictionary<string, Privilege>();
24 public static async Task<Privilege>
GetPrivilege(
string PrivilegeId)
26 await synchObj.BeginWrite();
29 return await GetPrivilegeLocked(PrivilegeId);
33 await synchObj.EndWrite();
37 private static async Task<Privilege> GetPrivilegeLocked(
string PrivilegeId)
47 int i = PrivilegeId.LastIndexOf(
'.');
51 ParentId =
string.Empty;
52 LocalId = PrivilegeId;
56 ParentId = PrivilegeId.Substring(0, i);
57 LocalId = PrivilegeId.Substring(i + 1);
60 Privilege =
new Privilege()
62 ParentFullId = ParentId,
65 Description = string.Empty
71 if (!
string.IsNullOrEmpty(Privilege.ParentFullId))
72 Privilege.Parent = await GetPrivilegeLocked(Privilege.ParentFullId);
74 privileges[PrivilegeId] = Privilege;
84 await synchObj.BeginWrite();
102 await synchObj.EndWrite();
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that have a named field equal to a given value.
Represents an object that allows single concurrent writers but multiple concurrent readers....
Corresponds to a privilege in the system.
Privilege Parent
Parent privilege.
string ParentFullId
Full Privilege ID of parent privilege. If the empty string, privilege is a root privilege.
string FullId
Full Privilege ID. Corresponds to the concatenation of ancestor IDs with the local ID,...
Maintains the collection of all privileges in the system.
static async Task LoadAll()
Loads all privileges
static async Task< Privilege > GetPrivilege(string PrivilegeId)
Gets the Privilege object corresponding to a full Privilege ID.