예제 #1
0
        /// <summary>
        /// Parses the specified <see cref="System.String"/> into the return type.
        /// </summary>
        /// <param name="parsedOption"></param>
        /// <returns>The parsed value.</returns>
        public TEnum?Parse(ParsedOption parsedOption)
        {
            if (parsedOption.HasValue == false)
            {
                return(null);
            }
            var parser = _parserFactory.CreateParser <TEnum>();

            return(parser.Parse(parsedOption));
        }
예제 #2
0
        /// <summary>
        /// Parses the specified <see cref="System.String"/> into the return type.
        /// </summary>
        /// <param name="parsedOption"></param>
        /// <returns>The parsed value.</returns>
        public List <T> Parse(ParsedOption parsedOption)
        {
            var parser = _parserFactory.CreateParser <T>();

            return(parsedOption.Values.Select(value =>
            {
                var clone = parsedOption.Clone();
                clone.Value = value;
                return parser.Parse(clone);
            }).ToList());
        }
        /// <summary>
        /// Parses the specified <see cref="ParsedOption"/> into a nullable type.
        /// </summary>
        public bool?Parse(ParsedOption parsedOption)
        {
            var parser = _parserFactory.CreateParser <bool>();

            if (parser.CanParse(parsedOption) == false)
            {
                return(null);
            }
            return(parser.Parse(parsedOption));
        }
예제 #4
0
        /// <summary>
        /// Parses the specified <see cref="ParsedOption"/> into a nullable type.
        /// </summary>
        public TNullableType?Parse(ParsedOption parsedOption)
        {
            var parser = _parserFactory.CreateParser <TNullableType>();

            if (parser.CanParse(parsedOption) == false)
            {
                return(null);
            }
            return(parser.Parse(parsedOption));
        }