static bool AreValidSearchArguments(string[] args, out string field, out string op, out string[] val) { field = op = ""; val = new string[10]; if (args.Length > 1) { switch (args[1].ToLower()) { case "date": { SearchDateArgument searchArgs = new SearchDateArgument(args); if (searchArgs.IsValid()) { field = searchArgs.Field; op = searchArgs.Criteria; val[0] = searchArgs.Date; val[1] = searchArgs.AnotherDate; Array.Resize(ref val, 2); return(true); } break; } case "description": { SearchDescriptionArgument searchArgs = new SearchDescriptionArgument(args); if (searchArgs.IsValid()) { field = searchArgs.Field; op = searchArgs.Criteria; val[0] = searchArgs.Value; Array.Resize(ref val, 1); return(true); } break; } case "tag": { SearchTagArgument searchArgs = new SearchTagArgument(args); if (searchArgs.IsValid()) { field = searchArgs.Field; op = searchArgs.Criteria; val = searchArgs.Values; return(true); } break; } default: { InvalidCommand(); return(false); } } } InvalidCommand(); return(false); }
static bool AreValidSearchArguments(string[] args, out string field, out string op, out string[] val) { field = op = ""; val = new string[10]; if (args.Length > 1) { switch (args[1].ToLower()) { case "date": { SearchDateArgument searchArgs = new SearchDateArgument(args); if (searchArgs.IsValid()) { field = searchArgs.Field; op = searchArgs.Criteria; val[0] = searchArgs.Date; val[1] = searchArgs.AnotherDate; Array.Resize(ref val, 2); return true; } break; } case "description": { SearchDescriptionArgument searchArgs = new SearchDescriptionArgument(args); if (searchArgs.IsValid()) { field = searchArgs.Field; op = searchArgs.Criteria; val[0] = searchArgs.Value; Array.Resize(ref val, 1); return true; } break; } case "tag": { SearchTagArgument searchArgs = new SearchTagArgument(args); if (searchArgs.IsValid()) { field = searchArgs.Field; op = searchArgs.Criteria; val = searchArgs.Values; return true; } break; } default: { InvalidCommand(); return false; } } } InvalidCommand(); return false; }