Skip to content
This repository was archived by the owner on Feb 10, 2022. It is now read-only.

Commit 3e480bf

Browse files
add comments for obsDict class
1 parent ae13c13 commit 3e480bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Type/Interfaces/ObserverableDictionary.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ public ObservableDictionary(IDictionary<TKey, TValue> dictionary)
3333
this.dictionary = dictionary;
3434
}
3535

36+
// AddWithNotification
3637
void AddWithNotification(KeyValuePair<TKey, TValue> item) => AddWithNotification(item.Key, item.Value);
3738

39+
// AddWithNotification
3840
void AddWithNotification(TKey key, TValue value)
3941
{
4042
dictionary.Add(key, value);
@@ -45,6 +47,7 @@ void AddWithNotification(TKey key, TValue value)
4547
PropertyChanged(this, new(nameof(dictionary.Values)));
4648
}
4749

50+
// RemoveWithNotification
4851
bool RemoveWithNotification(TKey key)
4952
{
5053
if (dictionary.TryGetValue(key, out TValue value) && dictionary.Remove(key))
@@ -60,6 +63,7 @@ bool RemoveWithNotification(TKey key)
6063
return false;
6164
}
6265

66+
// UpdateWithNotification
6367
void UpdateWithNotification(TKey key, TValue value)
6468
{
6569
if (dictionary.TryGetValue(key, out TValue existing))
@@ -161,11 +165,13 @@ public TValue this[TKey key]
161165

162166
#region ICollection<KeyValuePair<TKey,TValue>> Members
163167

168+
// ICollection
164169
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
165170
{
166171
AddWithNotification(item);
167172
}
168173

174+
// ICollection
169175
void ICollection<KeyValuePair<TKey, TValue>>.Clear()
170176
{
171177
dictionary.Clear();
@@ -176,31 +182,39 @@ void ICollection<KeyValuePair<TKey, TValue>>.Clear()
176182
PropertyChanged(this, new(nameof(dictionary.Values)));
177183
}
178184

185+
// ICollection
179186
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item) => dictionary.Contains(item);
180187

188+
// ICollection
181189
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
182190
{
183191
dictionary.CopyTo(array, arrayIndex);
184192
}
185193

194+
// ICollection
186195
int ICollection<KeyValuePair<TKey, TValue>>.Count
187196
{
188197
get => dictionary.Count;
189198
}
190199

200+
// ICollection
191201
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
192202
{
193203
get => dictionary.IsReadOnly;
194204
}
195205

206+
// ICollection
196207
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item) => RemoveWithNotification(item.Key);
197208

198209
#endregion
199210

200211
#region IEnumerable<KeyValuePair<TKey,TValue>> Members
201212

213+
214+
// IEnumerator
202215
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator() => dictionary.GetEnumerator();
203216

217+
// IEnumerator
204218
IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator();
205219

206220
#endregion

0 commit comments

Comments
 (0)