/// <summary> /// Advances the enumerator to the next command in the stream. /// </summary> /// <param name="context">The session context to use for making session based transitions.</param> /// <param name="tokenEnumerator">The token enumerator to accept the command from.</param> /// <param name="command">The command that is defined within the token enumerator.</param> /// <param name="errorResponse">The error that indicates why the command could not be made.</param> /// <returns>true if a valid command was found, false if not.</returns> public bool TryMake(SmtpSessionContext context, TokenEnumerator tokenEnumerator, out SmtpCommand command, out SmtpResponse errorResponse) { if (_states[_current].Transitions.TryGetValue(tokenEnumerator.Peek().Text, out _transition) == false) { var response = $"expected {String.Join("/", _states[_current].Transitions.Keys)}"; command = null; errorResponse = new SmtpResponse(SmtpReplyCode.SyntaxError, response); return(false); } if (_transition.Delegate(tokenEnumerator, out command, out errorResponse) == false) { return(false); } return(true); }