private static CommandLineArgsConfigurationProvider createLoadedProvider(string[] arguments, KeyNameBehavior keyBehavior, ParsingResultsErrorBehavior errorBehavor = ParsingResultsErrorBehavior.OnFirstError, bool allowAssignments = false, bool withRequiredValues = false) { var provider = createProvider(arguments, keyBehavior, errorBehavor, allowAssignments, withRequiredValues); provider.Load(); return(provider); }
private static CommandLineArgsConfigurationProvider createProvider(string[] arguments, KeyNameBehavior keyBehavior, ParsingResultsErrorBehavior errorBehavor = ParsingResultsErrorBehavior.OnFirstError, bool allowAssignments = false, bool withRequiredValues = false) { var src = new CommandLineArgsConfigurationSource(withRequiredValues ? CommandLineArgsTestDefinitions.DefinitionsWithValues : CommandLineArgsTestDefinitions.Definitions, arguments) { DuplicateKeyBehavior = keyBehavior, ParsingErrorBehavior = errorBehavor, AllowDirectAssignments = allowAssignments }; return(new CommandLineArgsConfigurationProvider(src)); }
private static IParsingResultsDictionary handleErrorsWithFunction(ParsingResultsErrorBehavior errorBehavior, IParsingResultsDictionary resultsDictionary, Action <IEnumerable <Exception> > errorFunction) { switch (errorBehavior) { case ParsingResultsErrorBehavior.OnFirstError: errorFunction(resultsDictionary.Errors.First().AsEnumerable().ToList()); break; case ParsingResultsErrorBehavior.Aggregate: errorFunction(resultsDictionary.Errors.ToList()); break; } return(ParsingResultsDictionary.CreateFailed(resultsDictionary.Errors.ToList())); }