- Timestamp:
- 06/17/19 10:40:41 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2924_DotNetCoreMigration/HeuristicLab.CommandLineInterface/CLIApplication.cs
r16985 r17013 51 51 SetOption(cmdData, option, (i + 1 < args.Length) ? args[++i] : ""); 52 52 // else check if arg is valid command, then jump to next command 53 else if (IsValidCommand(args[i], cmdData, out CommandData next)) { 53 else if (IsValidCommand(args[i], cmdData, out CommandData next)) { 54 54 CheckRequirements(cmdData); 55 55 valueIndex = 0; // reset value index for new command … … 163 163 /// Returns true when the given argument can be identified as help option (--help). 164 164 /// </summary> 165 private static bool IsHelpRequest(string arg) => arg. ToLower().Equals("--help");165 private static bool IsHelpRequest(string arg) => arg.Equals("--help", StringComparison.InvariantCultureIgnoreCase); 166 166 167 167 /// <summary> … … 185 185 private static bool IsValidCommand(string arg, CommandData cmdData, out CommandData next) { 186 186 foreach (var cmd in cmdData.Commands) { 187 if ( arg.ToLower().Equals(cmd.Identifier.ToLower())) {187 if (cmd.Identifier.Equals(arg, StringComparison.InvariantCultureIgnoreCase)) { 188 188 next = cmd; 189 189 return true; … … 213 213 /// </summary> 214 214 private static ICommand GetInstance(CommandData cmdData) { 215 if (cmdData.Instance == null) 215 if (cmdData.Instance == null) 216 216 cmdData.Instance = (ICommand)Activator.CreateInstance(cmdData.CommandType); 217 217 return cmdData.Instance; … … 226 226 IList list = (IList)CreateGenericType(typeof(List<>), targetType); 227 227 string[] elements = nextArg.Split(','); 228 foreach (var elem in elements) list.Add(ParseString(elem, targetType));228 foreach (var elem in elements) list.Add(ParseString(elem, targetType)); 229 229 property.SetValue(GetInstance(cmdData), list); 230 230 } else property.SetValue(GetInstance(cmdData), ParseString(nextArg, property.PropertyType)); … … 318 318 /// Valid = it implements ICommand and has a parameterless constructor. 319 319 /// </summary> 320 private static bool IsInstancableCommand(Type type) => 321 type.GetInterface(nameof(ICommand)) != null && 322 !type.IsAbstract && 323 !type.IsInterface && 320 private static bool IsInstancableCommand(Type type) => 321 type.GetInterface(nameof(ICommand)) != null && 322 !type.IsAbstract && 323 !type.IsInterface && 324 324 type.GetConstructors().Any(info => info.GetParameters().Length == 0); 325 325
Note: See TracChangeset
for help on using the changeset viewer.