Beispiel #1
0
 /// <summary>
 /// Creates an IInbox
 /// </summary>
 /// <param name="serverConfiguration">The mail server configuration</param>
 /// <param name="inBoxImplementationType">The type of inbox implementation</param>
 /// <param name="user">The user</param>
 /// <returns>An IInbox instance</returns>
 public IInbox GetInbox(IMailServerConfiguration serverConfiguration, 
     Type inBoxImplementationType,
     object user)
 {
     if (serverConfiguration == null) throw new NullArgumentException("serverConfiguration");
     if (inBoxImplementationType == null) throw new NullArgumentException("inboxImplementationType");
     if (user == null) throw new NullArgumentException("user");
     string replyAddress = serverConfiguration.ReplyAddress;
     lock (_inboxFactoringLock) {
         try {
             IInbox inbox = null;
             if (!_inboxes.TryGetValue(replyAddress, out inbox)) {
                 inbox = (IInbox)inBoxImplementationType.GetConstructor(new Type[0]).Invoke(null);
                 inbox.InboxServerConfiguration = serverConfiguration;
                 _inboxUsers[inbox] = 0;
                 _inboxes[replyAddress] = inbox;
                 inbox.BeginReceiving();
             }
             _userInboxes[user] = inbox;
             _inboxUsers[inbox] = _inboxUsers[inbox] + 1;
             return inbox;
         }
         catch (Exception ex) {
             throw new FailedToGetInboxException(serverConfiguration, inBoxImplementationType, user, ex);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Starts listening for incoming mails
 /// </summary>
 public virtual void BeginReceiving()
 {
     _inbox.BeginReceiving();
 }