MemoryMessageSpool.cs
上传用户:wdhx888
上传日期:2017-06-08
资源大小:112k
文件大小:1k
- namespace EricDaugherty.CSES.SmtpServer
- {
- using System;
- using System.Collections;
-
-
- /// <summary>
- /// Provides a memory based IMessageSpool.
- /// </summary>
- public class MemoryMessageSpool : IMessageSpool
- {
- #region Variables
-
- private Queue queue;
-
- #endregion
-
- /// <summary>
- /// Initializes the queue.
- /// </summary>
- public MemoryMessageSpool()
- {
- queue = new Queue();
- }
-
- #region IMessageSpool methods
-
- /// <summary>
- /// Addes the message to the in memory queue.
- /// </summary>
- /// <param name='message'>The message to queue.</param>
- public virtual bool SpoolMessage(SMTPMessage message)
- {
- queue.Enqueue( message );
- return true;
- }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>Returns the oldest message in the spool.</summary>
- public virtual SMTPMessage NextMessage()
- {
- return (SMTPMessage) queue.Dequeue();
- }
-
- /// <summary>Removes any messages from the spool.</summary>
- public virtual void ClearSpool()
- {
- queue.Clear();
- }
-
- #endregion
- }
- }