private void OnReferenceDisposed(SiteMailboxSynchronizer siteMailboxSynchronizer) { lock (this.lockObject) { SiteMailboxSynchronizerManager.SiteMailboxSynchronizerAndReferenceCount siteMailboxSynchronizerAndReferenceCount; if (!this.siteFolderMailboxSynchronizers.TryGetValue(siteMailboxSynchronizer.MailboxGuid, out siteMailboxSynchronizerAndReferenceCount) || siteMailboxSynchronizerAndReferenceCount.ReferenceCount == 0) { throw new InvalidOperationException(("The site mailbox synchronizer is already been removed. This should not happen. ReferenceCount = " + siteMailboxSynchronizerAndReferenceCount != null) ? siteMailboxSynchronizerAndReferenceCount.ReferenceCount.ToString() : "Null"); } siteMailboxSynchronizerAndReferenceCount.ReferenceCount--; } }
public SiteMailboxSynchronizerReference GetSiteMailboxSynchronizer(IExchangePrincipal siteMailboxPrincipal, string client) { SiteMailboxSynchronizerReference result; lock (this.lockObject) { SiteMailboxSynchronizerManager.SiteMailboxSynchronizerAndReferenceCount siteMailboxSynchronizerAndReferenceCount; if (!this.siteFolderMailboxSynchronizers.TryGetValue(siteMailboxPrincipal.MailboxInfo.MailboxGuid, out siteMailboxSynchronizerAndReferenceCount)) { SiteMailboxSynchronizer siteMailboxSynchronizer = new SiteMailboxSynchronizer(siteMailboxPrincipal, client); siteMailboxSynchronizerAndReferenceCount = new SiteMailboxSynchronizerManager.SiteMailboxSynchronizerAndReferenceCount(siteMailboxSynchronizer); this.siteFolderMailboxSynchronizers[siteMailboxPrincipal.MailboxInfo.MailboxGuid] = siteMailboxSynchronizerAndReferenceCount; } siteMailboxSynchronizerAndReferenceCount.ReferenceCount++; result = new SiteMailboxSynchronizerReference(siteMailboxSynchronizerAndReferenceCount.SiteMailboxSynchronizer, new Action <SiteMailboxSynchronizer>(this.OnReferenceDisposed)); } return(result); }
public SiteMailboxSynchronizerAndReferenceCount(SiteMailboxSynchronizer siteMailboxSynchronizer) { this.SiteMailboxSynchronizer = siteMailboxSynchronizer; }
public SiteMailboxSynchronizerReference(SiteMailboxSynchronizer siteMailboxSynchronizer, Action <SiteMailboxSynchronizer> onDispose) { this.siteMailboxSynchronizer = siteMailboxSynchronizer; this.onDispose = onDispose; }