/// <summary> /// Performs the actions required to handle a new store. /// </summary> /// <param name="rawStore">The new store. Ownership is transferred</param> private void StoreAdded(NSOutlook.Store rawStore) { IStore store = new StoreWrapper(rawStore); try { Logger.Instance.Trace(this, "New store: {0}", rawStore.DisplayName); AccountWrapper account = TryCreateFromRegistry(store); if (account == null) { // Add it to the cache so it is not evaluated again. _accountsByStoreId.Add(store.StoreID, null); Logger.Instance.Trace(this, "Not an account store: {0}", store.DisplayName); } else { Logger.Instance.Trace(this, "New account store: {0}: {1}", store.DisplayName, account); // Account has taken ownership of the store store = null; OnAccountDiscovered(account); } } catch (System.Exception e) { Logger.Instance.Error(this, "Event_StoreAdded Exception: {0}", e); } finally { store?.Dispose(); } }
// TODO: extension methods for this public static IStore Wrap(NSOutlook.Store obj, bool mustRelease = true) { if (obj == null) { return(null); } StoreWrapper wrapped = new StoreWrapper(obj); wrapped.MustRelease = mustRelease; return(wrapped); }