SmtpServer.Protocol.SmtpCommandFactory.TryMakeEhlo C# (CSharp) Method

TryMakeEhlo() public method

Make an EHLO command from the given enumerator.
public TryMakeEhlo ( TokenEnumerator enumerator, SmtpCommand &command, SmtpResponse &errorResponse ) : bool
enumerator SmtpServer.Protocol.Text.TokenEnumerator The enumerator to create the command from.
command SmtpCommand The EHLO command that is defined within the token enumerator.
errorResponse SmtpResponse The error that indicates why the command could not be made.
return bool
        public bool TryMakeEhlo(TokenEnumerator enumerator, out SmtpCommand command, out SmtpResponse errorResponse)
        {
            Debug.Assert(enumerator.Peek() == new Token(TokenKind.Text, "EHLO"));

            command = null;
            errorResponse = null;

            enumerator.Take();
            enumerator.TakeWhile(TokenKind.Space);

            string domain;
            if (_parser.TryMakeDomain(enumerator, out domain))
            {
                command = new EhloCommand(domain, _options);
                return true;
            }

            string address;
            if (_parser.TryMakeAddressLiteral(enumerator, out address))
            {
                command = new EhloCommand(address, _options);
                return true;
            }

            errorResponse = SmtpResponse.SyntaxError;
            return false;
        }