public MockReliableDictionary(Uri uri) : base(uri) { // Set the OnDictionaryChanged callback to fire the DictionaryChanged event. InternalDictionaryChanged += (sender, c) => { if (DictionaryChanged != null) { NotifyDictionaryChangedEventArgs <TKey, TValue> e = null; switch (c.ChangeType) { case ChangeType.Added: e = new NotifyDictionaryItemAddedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added); break; case ChangeType.Removed: e = new NotifyDictionaryItemRemovedEventArgs <TKey, TValue>(c.Transaction, c.Key); break; case ChangeType.Updated: e = new NotifyDictionaryItemUpdatedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added); break; } DictionaryChanged.Invoke(this, e); } MockDictionaryChanged?.Invoke(this, c); }; }
public MockReliableDictionary(Uri uri) : base(uri, null) { // Set the OnDictionaryChanged callback to fire the DictionaryChanged event. OnDictionaryChanged = (c) => { if (DictionaryChanged != null) { NotifyDictionaryChangedEventArgs <TKey, TValue> e; switch (c.ChangeType) { case ChangeType.Added: e = new NotifyDictionaryItemAddedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added); break; case ChangeType.Removed: e = new NotifyDictionaryItemRemovedEventArgs <TKey, TValue>(c.Transaction, c.Key); break; case ChangeType.Updated: e = new NotifyDictionaryItemUpdatedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added); break; default: return(false); } DictionaryChanged.Invoke(this, e); } MockDictionaryChanged?.Invoke(this, c); return(true); }; }