private static List <Tuple <Action <string, string>, string, string> > MatchActions( IReadOnlyList <string> args, IArgumentParseErrorHandler parseErrorHandler) { var actionMatcher = new ActionMatcher(); var solutionName = args[0]; var actionList = new List <Tuple <Action <string, string>, string, string> >(); var index = 1; while (index < args.Count) { var action = FindAction(args, parseErrorHandler, index, actionMatcher); var entityName = args[++index]; actionList.Add(new Tuple <Action <string, string>, string, string>(action, solutionName, entityName)); ++index; } return(actionList); }
private static Action <string, string> FindAction(IReadOnlyList <string> args, IArgumentParseErrorHandler parseErrorHandler, int index, ActionMatcher actionMatcher) { var key = args[index]; if (!key.StartsWith(Consts.KeyPrefix)) { parseErrorHandler.Handle(ArgumentParseErrorType.InvalidKey, key); throw new Exception(); } var action = actionMatcher.Match(key); if (action == null) { parseErrorHandler.Handle(ArgumentParseErrorType.UnknownKey, key); throw new Exception(); } return(action); }