static bool isSupported(string scope, out string[] items, out string unsupportedScope) { if (Supported is null) { items = new string[0]; unsupportedScope = scope; return(false); } var test = scope.Trim(); if (!test.Contains(Separator)) { unsupportedScope = string.Empty; if (test.Length == 0) { items = new string[0]; return(true); } if (Supported.Any(i => i.Equals(test, StringComparison.InvariantCultureIgnoreCase))) { items = new[] { test }; return(true); } unsupportedScope = test; items = new string[0]; return(false); } if (!tryParse(ref test, out items)) { throw invalidFormatError(scope); } var unsupported = new StringBuilder(); for (var i = 0; i < items.Length; i++) { if (IsScopeSupported(items[i], out _)) { continue; } unsupported.Append(items[i]); unsupported.Append(Separator); } if (unsupported.Length != 0) { unsupportedScope = unsupported.ToString().TrimEnd(); items = new string[0]; return(false); } unsupportedScope = string.Empty; return(true); }
public LogLevel(string Label, int Criticality, string ChibiLabel = null, ConsoleColor Color = ConsoleColor.Gray) { this.Name = Label; this.ChibiName = ChibiLabel ?? Label.Substring(0, 4); this.Criticality = Criticality; this.Color = Color; if (Supported.Any(p => string.Equals(p.Name, Label, StringComparison.OrdinalIgnoreCase))) { throw new InvalidLogLevelException($"Value entered for {nameof(Label)} ({Label}) is already in use."); } if (Supported.Any(p => string.Equals(p.ChibiName, ChibiLabel, StringComparison.OrdinalIgnoreCase))) { throw new InvalidLogLevelException($"Value entered for {nameof(ChibiLabel)} ({ChibiLabel}) is already in use."); } Supported.Add(this); gotPadding = false; }