Table of Contents

Class ObservableSet<T>

Namespace
NMF.Collections.ObjectModel
Assembly
NMF.Collections.dll

Denotes a set implementation that raises events when the collection contents are changed

public class ObservableSet<T> : DecoratedSet<T>, IList, ICollection, INotifyCollectionChanged, INotifyCollectionChanging, INotifyPropertyChanged, ISetExpression<T>, ISet<T>, ICollectionExpression<T>, IEnumerableExpression<T>, IEnumerableExpression, ICollection<T>, IEnumerable<T>, IEnumerable

Type Parameters

T
Inheritance
ObservableSet<T>
Implements
ISet<T>
Derived
Inherited Members
Extension Methods

Methods

Add(T)

Adds an element to the current set and returns a value to indicate if the element was successfully added.

public override bool Add(T item)

Parameters

item T

The element to add to the set.

Returns

bool

true if the element is added to the set; false if the element is already in the set.

AsNotifiable()

Gets notifications for this collection

public INotifyCollection<T> AsNotifiable()

Returns

INotifyCollection<T>

A collection that will notify clients as new elements change

Clear()

Removes all items from the ICollection<T>.

public override void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises CollectionChanged

protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)

Parameters

e NotifyCollectionChangedEventArgs

the event args

OnCollectionChanging(NotifyCollectionChangedEventArgs)

Raises CollectionChanging

protected void OnCollectionChanging(NotifyCollectionChangedEventArgs e)

Parameters

e NotifyCollectionChangedEventArgs

the event args

OnPropertyChanged(string)

Raises PropertyChanged

protected void OnPropertyChanged(string property)

Parameters

property string

the name of the property

Remove(T)

Removes the first occurrence of a specific object from the ICollection<T>.

public override bool Remove(T item)

Parameters

item T

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

RequireEvents()

Determines whether it is necessary to raise events

protected bool RequireEvents()

Returns

bool

True, if there is any subscriber to either CollectionChanged, CollectionChanging or PropertyChanged

SilentAdd(T)

Adds an element without notifications

protected bool SilentAdd(T item)

Parameters

item T

the item to add

Returns

bool

true, if successful, otherwise false

SilentClear()

Clears the collection contents without notifications

protected void SilentClear()

SilentRemove(T)

Removes the given item without notifications

protected bool SilentRemove(T item)

Parameters

item T

the item to remove

Returns

bool

true, if successful, otherwise false

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Events

CollectionChanged

Occurs when the collection changes.

public event NotifyCollectionChangedEventHandler CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

CollectionChanging

Gets raised when an attempt is made to change a given collection

public event EventHandler<NotifyCollectionChangedEventArgs> CollectionChanging

Event Type

EventHandler<NotifyCollectionChangedEventArgs>

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler