Exemplo n.º 1
0
            private void Replace(DictionaryModification <TKey, TValue> modification)
            {
                TValue existingValue;

                if (_dictionary._state.TryGetValue(modification.Key, out existingValue))
                {
                    _dictionary._subject.OnNext(DictionaryNotification.Replaced(modification.Key, modification.Value,
                                                                                existingValue));
                }
                else
                {
                    // TODO Should we do an upsert when the item to be replaced doesn't exist, or signal replaced with a missing value?
                    Upsert(modification);
                }
            }
            private void Replace(DictionaryModification <TKey, TValue> modification)
            {
                TValue existingValue;

                if (_dictionary._state.TryGetValue(modification.Key, out existingValue))
                {
                    _dictionary._state[modification.Key] = modification.Value;
                    _dictionary._subject.OnNext(DictionaryNotification.Replaced(modification.Key, modification.Value,
                                                                                existingValue));
                }
                else
                {
                    // Design decision: we do an upsert when the item to be replaced doesn't exist, rather than signal replaced with a missing value.
                    Upsert(modification);
                }
            }