W
Wavemaker
I'm writing a class that implements the IDictionary interface. Along
with this, I'm implementing an IDictionaryEnumerator class. For the
IDictionaryEnumerator, the documentation says the following:
"An enumerator remains valid as long as the collection remains
unchanged. If changes are made to the collection, such as adding,
modifying or deleting elements, the enumerator is irrecoverably
invalidated and the next call to MoveNext or Reset throws an
InvalidOperationException."
So any IDictionaryEnumerator object needs to be notified when its
related collection is changed in some way.
I was thinking about implementing this using an event. Whenever the
collection is changed, it triggers the event. Each time an
IDictionaryEnumerator is created, it registers itself with the
event so that it will be notified when its collection has changed
and can invalidate itself.
When an IDictionaryEnumerator recieves notification that the
collection has changed, it sets an flag to indicate that it's
invalid and also removes itself from the collection's invalidate
event so that it will not be notified more than once.
Make sense?
with this, I'm implementing an IDictionaryEnumerator class. For the
IDictionaryEnumerator, the documentation says the following:
"An enumerator remains valid as long as the collection remains
unchanged. If changes are made to the collection, such as adding,
modifying or deleting elements, the enumerator is irrecoverably
invalidated and the next call to MoveNext or Reset throws an
InvalidOperationException."
So any IDictionaryEnumerator object needs to be notified when its
related collection is changed in some way.
I was thinking about implementing this using an event. Whenever the
collection is changed, it triggers the event. Each time an
IDictionaryEnumerator is created, it registers itself with the
event so that it will be notified when its collection has changed
and can invalidate itself.
When an IDictionaryEnumerator recieves notification that the
collection has changed, it sets an flag to indicate that it's
invalid and also removes itself from the collection's invalidate
event so that it will not be notified more than once.
Make sense?