Example #1
0
        public Option(
            char?shortName,
            string?longName,
            ValueType valueType,
            Type objType,
            string?valueName = null,
            string?desc      = null,
            IValueSerializer?valueSerializer = null)
            : base(valueType, objType, valueName, desc, valueSerializer)
        {
            ThrowUtil.ThrowIfArgument(shortName == null && string.IsNullOrWhiteSpace(longName),
                                      $"{nameof(shortName)} and {nameof(longName)} can not both be null or empty.");

            if (shortName != null && !DebugUtil.IsValidOptionShortName(shortName.ToString()))
            {
                throw new ArgumentException(DebugUtil.InvalidOptionShortNameError(shortName.ToString()), nameof(shortName));
            }

            if (longName != null && !DebugUtil.IsValidOptionLongName(longName))
            {
                throw new ArgumentException(DebugUtil.InvalidOptionLongNameError(longName), nameof(longName));
            }

            if (!DebugUtil.IsValidOptionValueType(valueType))
            {
                throw new ArgumentException(DebugUtil.InvalidOptionValueTypeError(valueType), nameof(valueType));
            }

            LongName  = longName;
            ShortName = shortName;
        }