Exemple #1
0
        private static ParsedOptionsResult <T> CreateParseExceptionResult <T>(PropertyInfo exceptionProperty) where T : class
        {
            var parsedResult = new ParsedOptionsResult <T>();

            parsedResult.ParsedOptions = null;
            parsedResult.Result        = OptionsResult.ParsingException;

            var attribute = GetAttributeForProperty(exceptionProperty);

            parsedResult.ExceptionParameter = string.IsNullOrEmpty(attribute.LongName)
                ? exceptionProperty.Name.ToLowerInvariant()
                : attribute.LongName;

            return(parsedResult);
        }
Exemple #2
0
        private static ParsedOptionsResult <T> CreateResult <T>(T options,
                                                                List <PropertyInfo> optionParameterProperties, List <PropertyInfo> matchedProperties) where T : class
        {
            var parsedResult = new ParsedOptionsResult <T>();

            parsedResult.ParsedOptions = options;

            var missingRequiredOptions = FindUnsetRequiredOptions(optionParameterProperties, matchedProperties);

            parsedResult.MissingRequiredOptions = missingRequiredOptions;

            parsedResult.Result = missingRequiredOptions.Any()
                ? OptionsResult.MissingRequiredArgument
                : OptionsResult.Success;

            return(parsedResult);
        }