private ulong GetEnumValue(char flagName) { flagName = char.ToUpperInvariant(flagName); CommandHelpers.ValidateFlagName("flagName", flagName); for (int i = 0; i < _flagNamesAndValues.Length; i++) { if (_flagNamesAndValues[i].Key == flagName) { return(_flagNamesAndValues[i].Value); } } throw new ArgumentException("flagName"); }
private static string GetDefaultContextName() { string entryAssemblyName = Assembly .GetEntryAssembly() .GetName() .Name; char[] defaultContextName = null; for (int i = 0; i < entryAssemblyName.Length; i++) { char ch = entryAssemblyName[i]; if (CommandHelpers.IsValidNameCharacter(ch)) { if (defaultContextName != null) { defaultContextName[i] = ch; } continue; } if (defaultContextName == null) { defaultContextName = new char[entryAssemblyName.Length]; entryAssemblyName.CopyTo(0, defaultContextName, 0, i); } defaultContextName[i] = '_'; } return((defaultContextName != null) ? new string(defaultContextName) : entryAssemblyName); }
/// <summary> /// Initializes a new instance of the <see cref="T:Cmd.Net.VerbAttribute" /> class using the specified command name. /// </summary> /// <param name="verb">The name for a command.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="verb" /> is null.</exception> /// <exception cref="T:System.ArgumentException"><paramref name="verb" /> is an empty string (""), or contains one or more invalid characters.</exception> /// <remarks> /// A <paramref name="verb" /> can contain letters, digits and underscore characters. /// </remarks> public VerbAttribute(string verb) { CommandHelpers.ValidateName("verb", verb, false); _verb = verb; }
/// <summary> /// Initializes a new instance of the <see cref="T:Cmd.Net.ArgumentAttribute" /> class using the specified argument name. /// </summary> /// <param name="name">The name for an argument.</param> /// <exception cref="T:System.ArgumentException"><paramref name="name" /> contains one or more invalid characters.</exception> /// <remarks> /// A <paramref name="name" /> can be null, an empty string (""), or can contain letters, digits and underscore characters. /// </remarks> public ArgumentAttribute(string name) { CommandHelpers.ValidateName("name", name, true); _name = name ?? string.Empty; }