/// <summary> /// Method that sets up the command line arguments set. /// </summary> /// <returns></returns> public static CommandLineArguments <TOptions> Setup() { Type optionsType = typeof(TOptions); CommandLineOptionsAttribute options = optionsType.GetCustomAttributes(typeof(CommandLineOptionsAttribute), true).Cast <CommandLineOptionsAttribute>().FirstOrDefault(); // Walk all of the properties in the options file. PropertyInfo [] properties = optionsType.GetProperties(); List <PropertyArgumentAttribute> arguments = new List <PropertyArgumentAttribute>(); foreach (PropertyInfo propertyInfo in properties) { PropertyArgumentAttribute attribute = propertyInfo.GetCustomAttributes(typeof(PropertyArgumentAttribute), true).Cast <PropertyArgumentAttribute>().SingleOrDefault(); if (attribute != null) { attribute.Configure(propertyInfo); arguments.Add(attribute); } } return(new CommandLineArguments <TOptions>(options, arguments)); }
/// <summary> /// Constructor for the command line arguments /// </summary> /// <param name="options"></param> /// <param name="arguments"></param> private CommandLineArguments(CommandLineOptionsAttribute options, IEnumerable <PropertyArgumentAttribute> arguments) { _globalOptions = options; _arguments.AddRange(arguments); }