2 using System.Collections.Generic;
37 public static readonly List<PermissionPreset>
List =
new List<PermissionPreset>();
51 string permissionsStr = element.GetAttributeString(
"permissions",
"");
52 if (!Enum.TryParse(permissionsStr, out
Permissions))
54 DebugConsole.ThrowErrorLocalized(
"Error in permission preset \"" +
DisplayName +
"\" - " + permissionsStr +
" is not a valid permission!");
60 foreach (var subElement
in element.Elements())
62 if (!subElement.Name.ToString().Equals(
"command", StringComparison.OrdinalIgnoreCase)) {
continue; }
63 string commandName = subElement.GetAttributeString(
"name",
"");
65 DebugConsole.Command command = DebugConsole.FindCommand(commandName);
69 DebugConsole.ThrowErrorLocalized(
"Error in permission preset \"" +
DisplayName +
"\" - " + commandName +
"\" is not a valid console command.");
81 if (!File.Exists(file)) {
return; }
83 XDocument doc = XMLExtensions.TryLoadXml(file);
84 if (doc ==
null) {
return; }
87 foreach (XElement element
in doc.Root.Elements())
LocalizedString Fallback(LocalizedString fallback, bool useDefaultLanguageIfFound=true)
Use this text instead if the original text cannot be found.
readonly LocalizedString Description
static readonly List< PermissionPreset > List
readonly HashSet< DebugConsole.Command > PermittedCommands
readonly ClientPermissions Permissions
PermissionPreset(XElement element)
static void LoadAll(string file)
readonly Identifier Identifier
readonly LocalizedString DisplayName
bool MatchesPermissions(ClientPermissions permissions, ISet< DebugConsole.Command > permittedConsoleCommands)