UserCommand.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.IO;
  3. namespace Ant.Service.Utilities
  4. {
  5. /// <summary>
  6. /// This command represents a Pop3 USER command.
  7. /// </summary>
  8. internal sealed class UserCommand : Pop3Command<Pop3Response>
  9. {
  10. private string _username;
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="UserCommand"/> class.
  13. /// </summary>
  14. /// <param name="stream">The stream.</param>
  15. /// <param name="username">The username.</param>
  16. public UserCommand(Stream stream, string username)
  17. : base(stream, false, Pop3State.Authorization)
  18. {
  19. if (string.IsNullOrEmpty(username))
  20. {
  21. throw new ArgumentNullException("username");
  22. }
  23. _username = username;
  24. }
  25. /// <summary>
  26. /// Creates the USER request message.
  27. /// </summary>
  28. /// <returns>
  29. /// The byte[] containing the USER request message.
  30. /// </returns>
  31. protected override byte[] CreateRequestMessage()
  32. {
  33. return GetRequestMessage(Pop3Commands.User, _username, Pop3Commands.Crlf);
  34. }
  35. }
  36. }