Example #1
0
        /// <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);
        }
Example #2
0
 /// <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);
     }
 }
Example #3
0
 /// <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;
 }
Example #4
0
 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);
 }
Example #5
0
        /// <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;
        }
Example #7
0
            /// <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;
            }
Example #8
0
 /// <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);
 }
Example #9
0
 /// <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;
 }
Example #10
0
        /// <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);
        }
Example #11
0
 /// <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;
 }
Example #12
0
 /// <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);
     }
 }
Example #13
0
 /// <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);
 }
Example #14
0
 /// <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;
 }
Example #15
0
 /// <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);
 }
Example #16
0
 internal void SetParameterlessSwitch(ParameterlessSwitch parameterlessSwitch, string commandLineArg)
 {
     this.parameterlessSwitches[(int)parameterlessSwitch].commandLineArg = commandLineArg;
 }
Example #17
0
            /// <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;
            }