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.
public TrulyObservableOrderedSet()
items,
Items that the instance will contain. If there are duplicate items, they will be removed.
comparer = null
custom comparerer, used to check for duplicates. If no comparer is specified, EqualityComparer<T>.Default is used.
Properties
Indexers
this[]
#Gets or replaces an element in the ordered set at the specified index.
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
#Adds an object to the end of the ordered set if the set does not already contain the item.
public void Add()
T
item
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.
Clear
#Clears the ordered set.
public void Clear()
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.
Returns: True if the item is in the set; otherwise false.
IndexOf
#Searches for the specified object and returns the zero-based index of the first occurrence.
Returns: The zero-based index of the first occurrence of item if found; otherwise -1.
Insert
#Inserts an element at the specified index.
Exceptions:
| IndexOutOfRangeException | Thrown if the index passed is out of bounds. |
Remove
#Removes an element from the set.
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.
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.
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.