/// <summary>
        /// Adds the rules associated with a parameter.
        /// </summary>
        /// <param name="parameterRules">
        /// The rules associated with a parameter.
        /// </param>
        public void AddParameterRules(ParameterRules parameterRules)
        {
            if (parameterRules == null)
            {
                throw new ArgumentNullException("parameterRules");
            }

            string parameterName = this.isCaseSensitive ? parameterRules.ParameterName : parameterRules.ParameterName.ToUpperInvariant();
            this.rules.Add(parameterName, parameterRules);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to get the parameter rules associated with the specified parameter.
        /// </summary>
        /// <param name="parameterName">
        /// The parameter name.
        /// </param>
        /// <param name="parameterRules">
        /// The parameter rules associated with the specified parameter.
        /// </param>
        /// <returns>
        /// true: if the rules for the specified parameter were found, otherwise false.
        /// </returns>
        public bool TryGetParameterRules(string parameterName, out ParameterRules parameterRules)
        {
            if (parameterName == null)
            {
                throw new ArgumentNullException("parameterName");
            }

            parameterName = this.isCaseSensitive ? parameterName : parameterName.ToUpperInvariant();
            return(this.rules.TryGetValue(parameterName, out parameterRules));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the rules associated with a parameter.
        /// </summary>
        /// <param name="parameterRules">
        /// The rules associated with a parameter.
        /// </param>
        public void AddParameterRules(ParameterRules parameterRules)
        {
            if (parameterRules == null)
            {
                throw new ArgumentNullException("parameterRules");
            }

            string parameterName = this.isCaseSensitive ? parameterRules.ParameterName : parameterRules.ParameterName.ToUpperInvariant();

            this.rules.Add(parameterName, parameterRules);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParametersListRules"/> class.
        /// </summary>
        /// <param name="isCaseSensitive">
        /// Indicates if the parameters are case sensitive or not.
        /// </param>
        /// <param name="isHelpParameterAllowed">
        /// A value indicating whether the optional "/?" parameter is allowed.
        /// </param>
        public ParametersListRules(bool isCaseSensitive = false, bool isHelpParameterAllowed = false)
        {
            this.isCaseSensitive = isCaseSensitive;

            this.rules = new Dictionary <string, ParameterRules>();

            if (isHelpParameterAllowed)
            {
                this.AddParameterRules(ParameterRules.CreateParameter(HelpParameterName));
            }
        }
        /// <summary>
        /// Attempts to get the parameter rules associated with the specified parameter.
        /// </summary>
        /// <param name="parameterName">
        /// The parameter name.
        /// </param>
        /// <param name="parameterRules">
        /// The parameter rules associated with the specified parameter.
        /// </param>
        /// <returns>
        /// true: if the rules for the specified parameter were found, otherwise false.
        /// </returns>
        public bool TryGetParameterRules(string parameterName, out ParameterRules parameterRules)
        {
            if (parameterName == null)
            {
                throw new ArgumentNullException("parameterName");
            }

            parameterName = this.isCaseSensitive ? parameterName : parameterName.ToUpperInvariant();
            return this.rules.TryGetValue(parameterName, out parameterRules);
        }