private void Initialize() { commandInfos = new List <CommandInfo>(); properties = new List <ParameterInfo>(); foreach (var propertyInfo in ArgumentType.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { var attributes = propertyInfo.GetCustomAttributes <CommandLineAttribute>(true).ToArray(); if (attributes.Any()) { var parameterInfo = CreateInfo(propertyInfo, attributes); properties.Add(parameterInfo); if (parameterInfo is CommandInfo commandInfo) { commandInfos.Add(commandInfo); if (IsHelpCommand(propertyInfo)) { HelpCommand = commandInfo; } if (commandInfo.IsDefault) { if (DefaultCommand != null) { throw new InvalidOperationException("Default command was defined twice."); } DefaultCommand = commandInfo; } } } } }
private void Initialize() { commandInfos = new List <CommandInfo>(); properties = new List <ParameterInfo>(); foreach (var propertyInfo in ArgumentType.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { var attributes = (CommandLineAttribute[])propertyInfo.GetCustomAttributes(typeof(CommandLineAttribute), true); if (attributes.Any()) { var parameterInfo = CreateInfo(propertyInfo, attributes); properties.Add(parameterInfo); var commandInfo = parameterInfo as CommandInfo; if (commandInfo != null) { commandInfos.Add(commandInfo); if (IsHelpCommand(propertyInfo)) { HelpCommand = commandInfo; } } } } }