using System;
using System.IO;
namespace Ant.Service.Utilities
{
///
/// This class represents the Pop3 RETR command.
///
internal sealed class RetrCommand : Pop3Command
{
int _message;
///
/// Initializes a new instance of the class.
///
/// The stream.
/// The message.
public RetrCommand(Stream stream, int message)
: base(stream, true, Pop3State.Transaction)
{
if (message < 0)
{
throw new ArgumentOutOfRangeException("message");
}
_message = message;
}
///
/// Creates the RETR request message.
///
///
/// The byte[] containing the RETR request message.
///
protected override byte[] CreateRequestMessage()
{
return GetRequestMessage(Pop3Commands.Retr, _message.ToString(), Pop3Commands.Crlf);
}
///
/// Creates the response.
///
/// The buffer.
///
/// The Pop3Response containing the results of the
/// Pop3 command execution.
///
protected override RetrResponse CreateResponse(byte[] buffer)
{
Pop3Response response = Pop3Response.CreateResponse(buffer);
string[] messageLines = GetResponseLines(StripPop3HostMessage(buffer, response.HostMessage));
return new RetrResponse(response, messageLines);
}
}
}