TrulyObservableOrderedSet<T>
ReferencesAn ordered set that notifies its subscribers whenever one of its INotifyPropertyChanged elements raises its PropertyChanged event.
Remarks: This class prevents the removal of elements by assemblies they cannot be edited by. At the time of removal, each element's IAssemblyRestrictedObject.Editable() method will be invoked, and if false, an InvalidOperationException will be thrown.
Type parameters:
| T | A class that implements INotifyPropertyChanged as well as IAssemblyRestrictedObject where INotifyPropertyChanged, IAssemblyRestrictedObject |
Constructors
TrulyObservableOrderedSet
#Creates an instance with the given items.
Parameters:
| items (IEnumerable<T>) | Items that the instance will contain. If there are duplicate items, they will be removed. |
| comparer (IEqualityComparer<T> = null) | custom comparerer, used to check for duplicates. If no comparer is specified, EqualityComparer<T>.Default is used. |
TrulyObservableOrderedSet
#Creates an empty instance.
Parameters:
| comparer (IEqualityComparer<T> = null) |
Properties
Indexers
this[]
#Gets or replaces an element in the ordered set at the specified index.
Parameters:
| index (int) | The index of the element. |
Returns: the element at the given index.
Exceptions:
| IndexOutOfRangeException | Thrown if the index passed is out of bounds. |
| InvalidOperationException | Thrown if the item that will be replaced at the specified index cannot be modified by the current assembly. |
Methods
Add
#public void Add(T item)
Adds an object to the end of the ordered set if the set does not already contain the item.
Parameters:
| item (T) | The item to add. |
AddRange
#Add multiple objects to the end of the ordered set. Only distinct items are added. If new items were added, one CollectionChanged event is fired.
Parameters:
| items (IEnumerable<T>) |
Clear
#public void Clear()
Clears the ordered set.
Exceptions:
| InvalidOperationException | Thrown if at least one item currently in the set cannot be modified by the current assembly. |
Contains
#Determines whether an element is in the set.
Parameters:
| item (T) | The item to check for inclusion. |
Returns: True if the item is in the set; otherwise false.
CopyTo
#Copies the values of the set to an array.
Parameters:
| array (T[]) | The array to copy the values to. |
| arrayIndex (int) | The index of the array to start the copy. |
GetEnumerator
#Returns an enumerator that iterates through the set.
IndexOf
#Searches for the specified object and returns the zero-based index of the first occurrence.
Parameters:
| item (T) | The item to locate. |
Returns: The zero-based index of the first occurrence of item if found; otherwise -1.
Insert
#Inserts an element at the specified index.
Parameters:
| index (int) | The index to insert the element at. |
| item (T) | The item to insert. |
Exceptions:
| IndexOutOfRangeException | Thrown if the index passed is out of bounds. |
Remove
#Removes an element from the set.
Parameters:
| item (T) | The element to remove. |
Returns: Returns true if the element was removed; otherwise returns false.
Exceptions:
| InvalidOperationException | Thrown if the item that will be removed cannot be modified by the current assembly. |
RemoveAt
#Removes an element at the specified index from the set.
Parameters:
| index (int) | The index of the element to remove. |
Exceptions:
| IndexOutOfRangeException | Thrown if the index passed is out of bounds. |
| InvalidOperationException | Thrown if the item that will be removed cannot be modified by the current assembly. |
RemoveRange
#Remove a number of items. If at least one item was removed, one CollectionChanged event is fired.
Parameters:
| items (IEnumerable<T>) |
Returns: true if at least one item was removed
Sort<TKey>
#Sorts the set.
Returns an enumerator that iterates through the dictionary.
Events
CollectionChanged
#Triggered whenever the set changes or when one of its elements has its PropertyChanged event triggered.