namespace zero.Identity;
public struct PermissionGroup
{
///
/// Full key of the group
///
public string Key { get; set; }
///
/// Title of this permission group for output
///
public string Label { get; set; }
///
/// Permissions for this group
///
public HashSet Permissions { get; set; }
public PermissionGroup(string key, string label)
{
Key = key;
Label = label;
Permissions = new();
}
///
/// Add a new permission to this group
///
public void Add(Permission permission)
{
Permissions.Add(permission);
}
///
/// Remove a permission
///
public void Remove(Permission permission)
{
Permissions.Remove(permission);
}
///
/// Get permission by key
///
public Permission? Get(string key)
{
return Permissions.FirstOrDefault(x => x.Key == key);
}
///
/// Get permission by key
///
public object this[string key]
{
get => Permissions.FirstOrDefault(x => x.Key == key);
}
}