internal static void FormatParameters(string[] parameters) { if (parameters == null) { return; } bool flag = false; for (int i = 0; i < parameters.Length; i++) { if (parameters[i].Length < 1) { throw new FormatException(DataStrings.ParameterNameEmptyException); } if (RoleEntry.ContainsInvalidChars(parameters[i])) { throw new FormatException(DataStrings.ParameterNameInvalidCharException(parameters[i])); } if (!flag && i < parameters.Length - 1 && string.Compare(parameters[i], parameters[i + 1], StringComparison.OrdinalIgnoreCase) >= 0) { flag = true; } } if (flag) { Array.Sort <string>(parameters, StringComparer.OrdinalIgnoreCase); for (int j = 0; j < parameters.Length - 1; j++) { if (string.Equals(parameters[j], parameters[j + 1], StringComparison.OrdinalIgnoreCase)) { throw new FormatException(DataStrings.DuplicateParameterException(parameters[j])); } } } }
internal new static void ValidateName(string name) { if (string.IsNullOrEmpty(name)) { throw new FormatException(DataStrings.CmdletFullNameFormatException(name ?? string.Empty)); } int num = name.IndexOf(','); if (-1 == num) { if (RoleEntry.ContainsInvalidChars(name)) { throw new FormatException(DataStrings.CmdletFullNameFormatException(name)); } } else { if (num == 0 || name.Length - 1 == num) { throw new FormatException(DataStrings.CmdletFullNameFormatException(name)); } if (RoleEntry.ContainsInvalidChars(name, 0, num)) { throw new FormatException(DataStrings.CmdletFullNameFormatException(name)); } if (RoleEntry.ContainsInvalidChars(name, 1 + num, name.Length - num - 1)) { throw new FormatException(DataStrings.CmdletFullNameFormatException(name)); } } }
internal CmdletRoleEntry(string entryString) { int num = base.ExtractAndSetName(entryString); if (num <= 0 || num == entryString.Length) { throw new FormatException(DataStrings.SnapinNameTooShort); } num = this.ParseVersion(entryString, num); int num2 = entryString.IndexOf(',', num) + 1; int num3 = ((num2 <= 0) ? entryString.Length : (num2 - 1)) - num; if (num3 < 1) { throw new FormatException(DataStrings.SnapinNameTooShort); } base.ExtractAndSetParameters(entryString, num2); string text = entryString.Substring(num, num3); if (RoleEntry.ContainsInvalidChars(text)) { throw new FormatException(DataStrings.SnapinNameInvalidCharException(text)); } this.snapinName = text; this.fullName = this.snapinName + "\\" + base.Name; }
internal static void ValidateName(string name) { if (string.IsNullOrEmpty(name)) { throw new FormatException(DataStrings.RoleEntryNameInvalidException(name ?? string.Empty)); } if (RoleEntry.ContainsInvalidChars(name)) { throw new FormatException(DataStrings.RoleEntryNameInvalidException(name)); } }
internal CmdletRoleEntry(string name, string snapinName, string[] parameters) : base(name, parameters) { if (string.IsNullOrEmpty(snapinName)) { throw new FormatException(DataStrings.SnapinNameTooShort); } if (RoleEntry.ContainsInvalidChars(snapinName)) { throw new FormatException(DataStrings.SnapinNameInvalidCharException(snapinName)); } this.snapinName = snapinName; this.fullName = this.snapinName + "\\" + base.Name; }
protected static bool ContainsInvalidChars(string valueToCheck) { return(RoleEntry.ContainsInvalidChars(valueToCheck, 0, valueToCheck.Length)); }