public void Execute(List <Query> queries) { for (int x = 0; x < queries.Count; x++) { Query query = queries[x]; if (!query.IsOption && (x == queries.Count - 1 || !queries[x + 1].IsOption)) { ExecuteStack(ExecutionStack.Count > 1); } if (query.IsOption) { if (ExecutionStack.Count == 0) { OnMessage.Invoke(new Message(EMessageType.Error, Localization.Get(ELocKey.LogicOptionWithoutCommand))); return; } else { AConsoleCommand option = query.GetCommand(this); AConsoleCommand command = ExecutionStack[0].GetCommand(this); if (!command.IsOptionValid(option.GetType())) { string message = Localization.Get(ELocKey.LogicOptionInvalid, option.Name, command.Name); OnMessage.Invoke(new Message(EMessageType.Error, message)); return; } } } ExecutionStack.Add(query); } ExecuteStack(ExecutionStack.Count > 1); ExecutionStack.Clear(); }
private void HandleQueries(List <Query> queries) { bool processingOptions = false; Stack <Query> batch = new Stack <Query>(); for (int x = 0; x < queries.Count; x++) { Query query = queries[x]; if (processingOptions && !query.IsOption) { m_PendingBatches.Enqueue(batch); batch = new Stack <Query>(); } processingOptions = query.IsOption; if (processingOptions) { if (batch.Count == 0) { OnMessage.Invoke(new Message(EMessageType.Error, Localization.Get(ELocKey.LogicOptionWithoutCommand))); return; } else { AConsoleCommand option = query.GetCommand(this); AConsoleCommand command = batch.Peek().GetCommand(this); if (command == null) { OnMessage.Invoke(new Message(EMessageType.Error, Localization.Get(ELocKey.LogicCommandNotFound, query.Name.Value))); } else if (!command.IsOptionValid(option.GetType())) { string message = Localization.Get(ELocKey.LogicOptionInvalid, option.Name, command.Name); OnMessage.Invoke(new Message(EMessageType.Error, message)); return; } } } batch.Push(query); } if (batch.Count > 0) { m_PendingBatches.Enqueue(batch); } }