/// <summary> /// Identifies/detects a switch that takes no parameters. /// </summary> /// <param name="switchName"></param> /// <param name="parameterlessSwitch">[out] switch identifier (from ParameterlessSwitch enumeration)</param> /// <param name="duplicateSwitchErrorMessage"></param> /// <returns>true, if switch is a recognized switch that doesn't take parameters</returns> internal static bool IsParameterlessSwitch ( string switchName, out ParameterlessSwitch parameterlessSwitch, out string duplicateSwitchErrorMessage ) { parameterlessSwitch = ParameterlessSwitch.Invalid; duplicateSwitchErrorMessage = null; foreach (ParameterlessSwitchInfo switchInfo in s_parameterlessSwitchesMap) { foreach (string parameterlessSwitchName in switchInfo.switchNames) { if (String.Compare(switchName, parameterlessSwitchName, StringComparison.OrdinalIgnoreCase) == 0) { parameterlessSwitch = switchInfo.parameterlessSwitch; duplicateSwitchErrorMessage = switchInfo.duplicateSwitchErrorMessage; break; } } } return(parameterlessSwitch != ParameterlessSwitch.Invalid); }
/// <summary> /// Gets the on/off state on the command line of the given parameterless switch. /// </summary> /// <remarks> /// This indexer is functionally equivalent to IsParameterlessSwitchSet, but semantically very different. /// </remarks> /// <param name="parameterlessSwitch"></param> /// <returns>true if on, false if off</returns> internal bool this[ParameterlessSwitch parameterlessSwitch] { get { return(_parameterlessSwitches[(int)parameterlessSwitch].commandLineArg != null); } }
/// <summary> /// Initializes struct data. /// </summary> /// <param name="switchNames"></param> /// <param name="parameterlessSwitch"></param> /// <param name="duplicateSwitchErrorMessage"></param> internal ParameterlessSwitchInfo ( string[] switchNames, ParameterlessSwitch parameterlessSwitch, string duplicateSwitchErrorMessage ) { this.switchNames = switchNames; this.duplicateSwitchErrorMessage = duplicateSwitchErrorMessage; this.parameterlessSwitch = parameterlessSwitch; }
private string[] GetSpecificFileLoggerParameters(ParameterlessSwitch parameterlessSwitch, ParameterizedSwitch parameterizedSwitch) { string[] strArray = null; if (this.IsParameterizedSwitchSet(parameterizedSwitch)) { return(this[parameterizedSwitch]); } if (this.IsParameterlessSwitchSet(parameterlessSwitch)) { strArray = new string[0]; } return(strArray); }
/// <summary> /// If the specified parameterized switch is set, returns the array of parameters. /// Otherwise, if the specified parameterless switch is set, returns an empty array. /// Otherwise returns null. /// This allows for example "/flp:foo=bar" to imply "/fl". /// </summary> private string[] GetSpecificFileLoggerParameters(ParameterlessSwitch parameterlessSwitch, ParameterizedSwitch parameterizedSwitch) { string[] result = null; if (IsParameterizedSwitchSet(parameterizedSwitch)) { result = this[parameterizedSwitch]; } else if (IsParameterlessSwitchSet(parameterlessSwitch)) { result = Array.Empty <string>(); } return(result); }
/// <summary> /// If the specified parameterized switch is set, returns the array of parameters. /// Otherwise, if the specified parameterless switch is set, returns an empty array. /// Otherwise returns null. /// This allows for example "/flp:foo=bar" to imply "/fl". /// </summary> private string[] GetSpecificFileLoggerParameters(ParameterlessSwitch parameterlessSwitch, ParameterizedSwitch parameterizedSwitch) { string[] result = null; if (IsParameterizedSwitchSet(parameterizedSwitch)) { result = this[parameterizedSwitch]; } else if (IsParameterlessSwitchSet(parameterlessSwitch)) { result = new string[] { }; } return result; }
/// <summary> /// Initializes struct data. /// </summary> /// <param name="switchNames"></param> /// <param name="parameterlessSwitch"></param> /// <param name="duplicateSwitchErrorMessage"></param> internal ParameterlessSwitchInfo ( string[] switchNames, ParameterlessSwitch parameterlessSwitch, string duplicateSwitchErrorMessage, string lightUpRegistryKey ) { this.switchNames = switchNames; this.duplicateSwitchErrorMessage = duplicateSwitchErrorMessage; this.parameterlessSwitch = parameterlessSwitch; this.lightUpKey = lightUpRegistryKey; this.lightUpKeyRead = false; this.lightUpKeyResult = false; }
/// <summary> /// Indicates if the given switch that doesn't take parameters has already been detected on the command line. /// </summary> /// <param name="parameterlessSwitch"></param> /// <returns>true, if switch has been seen before</returns> internal bool IsParameterlessSwitchSet(ParameterlessSwitch parameterlessSwitch) { return(_parameterlessSwitches[(int)parameterlessSwitch].commandLineArg != null); }
/// <summary> /// Called when a recognized switch that doesn't take parameters is detected on the command line. /// </summary> /// <param name="parameterlessSwitch"></param> internal void SetParameterlessSwitch(ParameterlessSwitch parameterlessSwitch, string commandLineArg) { // save the switch text _parameterlessSwitches[(int)parameterlessSwitch].commandLineArg = commandLineArg; }
/// <summary> /// Identifies/detects a switch that takes no parameters. /// </summary> /// <param name="switchName"></param> /// <param name="parameterlessSwitch">[out] switch identifier (from ParameterlessSwitch enumeration)</param> /// <param name="duplicateSwitchErrorMessage"></param> /// <returns>true, if switch is a recognized switch that doesn't take parameters</returns> internal static bool IsParameterlessSwitch ( string switchName, out ParameterlessSwitch parameterlessSwitch, out string duplicateSwitchErrorMessage ) { parameterlessSwitch = ParameterlessSwitch.Invalid; duplicateSwitchErrorMessage = null; foreach (ParameterlessSwitchInfo switchInfo in s_parameterlessSwitchesMap) { if (IsParameterlessSwitchEnabled(switchInfo)) { foreach (string parameterlessSwitchName in switchInfo.switchNames) { if (String.Compare(switchName, parameterlessSwitchName, StringComparison.OrdinalIgnoreCase) == 0) { parameterlessSwitch = switchInfo.parameterlessSwitch; duplicateSwitchErrorMessage = switchInfo.duplicateSwitchErrorMessage; break; } } } } return (parameterlessSwitch != ParameterlessSwitch.Invalid); }
/// <summary> /// Gets the command line argument (if any) in which the given parameterless switch was detected. /// </summary> /// <param name="parameterlessSwitch"></param> /// <returns>The switch text, or null if switch was not detected on the command line.</returns> internal string GetParameterlessSwitchCommandLineArg(ParameterlessSwitch parameterlessSwitch) { return _parameterlessSwitches[(int)parameterlessSwitch].commandLineArg; }
/// <summary> /// Gets the on/off state on the command line of the given parameterless switch. /// </summary> /// <remarks> /// This indexer is functionally equivalent to IsParameterlessSwitchSet, but semantically very different. /// </remarks> /// <param name="parameterlessSwitch"></param> /// <returns>true if on, false if off</returns> internal bool this[ParameterlessSwitch parameterlessSwitch] { get { return (_parameterlessSwitches[(int)parameterlessSwitch].commandLineArg != null); } }
/// <summary> /// Indicates if the given switch that doesn't take parameters has already been detected on the command line. /// </summary> /// <param name="parameterlessSwitch"></param> /// <returns>true, if switch has been seen before</returns> internal bool IsParameterlessSwitchSet(ParameterlessSwitch parameterlessSwitch) { return (_parameterlessSwitches[(int)parameterlessSwitch].commandLineArg != null); }
/// <summary> /// Gets the command line argument (if any) in which the given parameterless switch was detected. /// </summary> /// <param name="parameterlessSwitch"></param> /// <returns>The switch text, or null if switch was not detected on the command line.</returns> internal string GetParameterlessSwitchCommandLineArg(ParameterlessSwitch parameterlessSwitch) { return(_parameterlessSwitches[(int)parameterlessSwitch].commandLineArg); }
internal void SetParameterlessSwitch(ParameterlessSwitch parameterlessSwitch, string commandLineArg) { this.parameterlessSwitches[(int)parameterlessSwitch].commandLineArg = commandLineArg; }