public static List <CommandLineArgumentException> Validate(NameValueCollection nameValueArgs, CommandLineArgDescriptorList commandLineArgDescriptorList) { if (commandLineArgDescriptorList == null) { throw new ArgumentNullException("commandLineArgDescriptorList"); } List <CommandLineArgumentException> list = new List <CommandLineArgumentException>(); foreach (CommandLineArgDescriptor descriptor in commandLineArgDescriptorList) { string[] values = nameValueArgs.GetValues(descriptor.Named ? descriptor.Name : null); int num = (values == null) ? 0 : values.Length; if (num < descriptor.MinOccurs) { CommandLineArgumentException item = new CommandLineArgumentException(CommandLineResources.GetFormattedString(CommandLineResources.ResourceID.RequiredArgumentNotSpecified, new object[] { descriptor.MinOccurs.ToString(CultureInfo.InvariantCulture) }), descriptor.Name, TraceLevel.Error); list.Add(item); } else if (num > descriptor.MaxOccurs) { CommandLineArgumentException exception2 = new CommandLineArgumentException(CommandLineResources.GetFormattedString(CommandLineResources.ResourceID.ExtraArgumentsSpecified, new object[] { descriptor.MaxOccurs.ToString(CultureInfo.InvariantCulture) }), descriptor.Name, TraceLevel.Error); list.Add(exception2); } } for (int i = 0; i < nameValueArgs.Count; i++) { string key = nameValueArgs.GetKey(i); string[] strArray2 = nameValueArgs.GetValues(i); if (key != null) { CommandLineArgDescriptor descriptor2 = commandLineArgDescriptorList.GetDescriptor(key); if (descriptor2 == null) { CommandLineArgumentException exception3 = new CommandLineArgumentException(CommandLineResources.GetString(CommandLineResources.ResourceID.UnrecognizedNamedArgument), key, TraceLevel.Error); list.Add(exception3); } else if (descriptor2.Type == CommandLineArgDescriptor.ArgumentType.Simple) { if ((strArray2 != null) && (strArray2.Length > 0)) { CommandLineArgumentException exception4 = new CommandLineArgumentException(CommandLineResources.GetString(CommandLineResources.ResourceID.ValueForSimpleArgument), key, TraceLevel.Error); list.Add(exception4); } } else if ((descriptor2.Type == CommandLineArgDescriptor.ArgumentType.Boolean) && ((strArray2 == null) || (((strArray2 != null) && (strArray2[0] != "+")) && (strArray2[0] != "-")))) { CommandLineArgumentException exception5 = new CommandLineArgumentException(CommandLineResources.GetString(CommandLineResources.ResourceID.NoFlagForBooleanArgument), key, TraceLevel.Error); list.Add(exception5); } } } return(list); }