Beispiel #1
0
            /// <summary>
            /// Create a new instance.
            /// </summary>
            /// <param name="commandName">The name of the command.</param>
            /// <param name="implementingType">The <see cref="Type"/> implementing the command.</param>
            /// <param name="descriptions">The localised descriptions for the command.</param>
            public Builder(string commandName, Type implementingType, ITextResolver descriptions)
            {
                if (commandName == null)
                {
                    throw new ArgumentNullException(nameof(commandName));
                }

                if (commandName == string.Empty)
                {
                    throw new ArgumentException(string.Format(Texts.ArgumentCannotBeEmpty, nameof(commandName)), nameof(commandName));
                }

                if (implementingType == null)
                {
                    throw new ArgumentNullException(nameof(implementingType));
                }

                if (descriptions == null)
                {
                    throw new ArgumentNullException(nameof(descriptions));
                }

                _commandName      = commandName;
                _implementingType = implementingType;
                _descriptions     = descriptions;
            }
Beispiel #2
0
        /// <summary>
        /// Create a new instance.
        /// </summary>
        /// <param name="property">The property the parameter will be bound to.</param>
        /// <param name="descriptions">The descriptions for the parameter.</param>
        /// <param name="required">Indicates whether the parameter is required or not.</param>
        protected ParameterDescriptor(PropertyInfo property, ITextResolver descriptions, bool required)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            if (descriptions == null)
            {
                throw new ArgumentNullException(nameof(descriptions));
            }

            Property      = property;
            _descriptions = descriptions;
            Required      = required;
        }
Beispiel #3
0
        /// <summary>
        /// Create a new instance.
        /// </summary>
        /// <param name="name">The name of the parameter.</param>
        /// <param name="property">The property the parameter will be bound to.</param>
        /// <param name="descriptions">The descriptions for the parameter.</param>
        /// <param name="required">Indicates whether the parameter is required or not.</param>
        public FlagParameterDescriptor(string name, PropertyInfo property, ITextResolver descriptions, bool required)
            : base(property, descriptions, required)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(string.Format(Texts.ArgumentCannotBeEmptyOrWhitespace, nameof(name)), nameof(name));
            }

            if (required)
            {
                throw new ArgumentException(Texts.FlagParametersCannotBeRequired, nameof(required));
            }

            Name = name;
        }
Beispiel #4
0
 private CommandDescriptor(string commandName, Type implementingType, ITextResolver descriptions)
 {
     CommandName      = commandName;
     ImplementingType = implementingType;
     _descriptions    = descriptions;
 }
        /// <summary>
        /// Create a new instance.
        /// </summary>
        /// <param name="name">The name of the parameter.</param>
        /// <param name="valuePlaceholderText">The placeholder text for the parameter value.</param>
        /// <param name="property">The property the parameter will be bound to.</param>
        /// <param name="descriptions">The descriptions for the parameter.</param>
        /// <param name="required">Indicates whether the parameter is required or not.</param>
        public NamedParameterDescriptor(string name, string valuePlaceholderText, PropertyInfo property, ITextResolver descriptions, bool required)
            : base(property, descriptions, required)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(string.Format(Texts.ArgumentCannotBeEmptyOrWhitespace, nameof(name)), nameof(name));
            }

            if (valuePlaceholderText == null)
            {
                throw new ArgumentNullException(nameof(valuePlaceholderText));
            }

            if (string.IsNullOrWhiteSpace(valuePlaceholderText))
            {
                throw new ArgumentException(string.Format(Texts.ArgumentCannotBeEmptyOrWhitespace, nameof(valuePlaceholderText)), nameof(valuePlaceholderText));
            }

            Name = name;
            ValuePlaceholderText = valuePlaceholderText;
        }
        /// <summary>
        /// Create a new instance.
        /// </summary>
        /// <param name="number">The number of the numbered parameter.</param>
        /// <param name="placeholderText">The placeholder text for the parameter.</param>
        /// <param name="property">The property the parameter will be bound to.</param>
        /// <param name="descriptions">The descriptions for the parameter.</param>
        /// <param name="required">Indicates whether the parameter is required or not.</param>
        public NumberedParameterDescriptor(int number, string placeholderText, PropertyInfo property, ITextResolver descriptions, bool required)
            : base(property, descriptions, required)
        {
            if (number <= 0)
            {
                throw new ArgumentException(string.Format(Texts.ArgumentMustBeGreaterThanZero, nameof(number)), nameof(number));
            }

            if (placeholderText == null)
            {
                throw new ArgumentNullException(nameof(placeholderText));
            }

            if (placeholderText.Equals(string.Empty))
            {
                throw new ArgumentException(string.Format(Texts.ArgumentCannotBeEmpty, nameof(placeholderText)), nameof(placeholderText));
            }

            Number          = number;
            PlaceholderText = placeholderText;
        }