TrulyObservableOrderedSet<T>

References
An 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.
TA 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.
)

TrulyObservableOrderedSet

#
Creates an empty instance.
public TrulyObservableOrderedSet(
comparer = null
)

Properties

Count

#
Returns the total number of items in the set.
public int Count { get; }

IsReadOnly

#
Always returns false.
public bool IsReadOnly { get; }

Indexers

this[]

#
Gets or replaces an element in the ordered set at the specified index.
public T this[
index
The index of the element.
] { get; set; }
the element at the given index.
IndexOutOfRangeExceptionThrown if the index passed is out of bounds.
InvalidOperationExceptionThrown 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.
public void AddRange(
items
)

Clear

#
Clears the ordered set.
public void Clear()
InvalidOperationExceptionThrown 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.
public bool Contains(
T
item
The item to check for inclusion.
)
True if the item is in the set; otherwise false.

CopyTo

#
Copies the values of the set to an array.
public void CopyTo(
T[]
array,
The array to copy the values to.
arrayIndex
The index of the array to start the copy.
)

GetEnumerator

#
Returns an enumerator that iterates through the set.
public IEnumerator<T> GetEnumerator()

IndexOf

#
Searches for the specified object and returns the zero-based index of the first occurrence.
public int IndexOf(
T
item
The item to locate.
)
The zero-based index of the first occurrence of item if found; otherwise -1.

Insert

#
Inserts an element at the specified index.
public void Insert(
index,
The index to insert the element at.
T
item
The item to insert.
)
IndexOutOfRangeExceptionThrown if the index passed is out of bounds.

Remove

#
Removes an element from the set.
public bool Remove(
T
item
The element to remove.
)
Returns true if the element was removed; otherwise returns false.
InvalidOperationExceptionThrown 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.
public void RemoveAt(
index
The index of the element to remove.
)
IndexOutOfRangeExceptionThrown if the index passed is out of bounds.
InvalidOperationExceptionThrown 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.
public bool RemoveRange(
items
)
true if at least one item was removed

Sort<TKey>

#
Sorts the set.
public void Sort<TKey>(
Func<T, TKey>
keySelector,
descending = false
If true, the sort will happen in descending other; if false, it will happen in ascending order.
)
Explicit

IEnumerable.GetEnumerator

#
Returns an enumerator that iterates through the dictionary.
IEnumerator IEnumerable.GetEnumerator()

Events

CollectionChanged

#
Triggered whenever the set changes or when one of its elements has its PropertyChanged event triggered.
public event NotifyCollectionChangedEventHandler CollectionChanged