Class OppositeList<TParent, TCollected>
- Namespace
- NMF.Collections.ObjectModel
- Assembly
- NMF.Collections.dll
Denotes the abstract base class for a list with opposites
public abstract class OppositeList<TParent, TCollected> : Collection<TCollected>, IList<TCollected>, ICollection<TCollected>, IReadOnlyList<TCollected>, IReadOnlyCollection<TCollected>, IEnumerable<TCollected>, IList, ICollection, IEnumerable
Type Parameters
TParentthe type of the parent element
TCollectedthe type of collection items
- Inheritance
-
Collection<TCollected>OppositeList<TParent, TCollected>
- Implements
-
IList<TCollected>ICollection<TCollected>IReadOnlyList<TCollected>IReadOnlyCollection<TCollected>IEnumerable<TCollected>
- Inherited Members
Constructors
OppositeList(TParent)
Creates a new instance
protected OppositeList(TParent parent)
Parameters
parentTParentthe parent model element
Exceptions
- ArgumentNullException
thrown if parent is null
Properties
Parent
Gets the parent element
public TParent Parent { get; }
Property Value
- TParent
Methods
ClearItems()
Removes all elements from the Collection<T>.
protected override void ClearItems()
InsertItem(int, TCollected)
Inserts an element into the Collection<T> at the specified index.
protected override void InsertItem(int index, TCollected item)
Parameters
indexintThe zero-based index at which
itemshould be inserted.itemTCollectedThe object to insert. The value can be null for reference types.
Exceptions
- ArgumentOutOfRangeException
<code class="paramref">index</code> is less than zero.-or-
indexis greater than Count.
RemoveItem(int)
Removes the element at the specified index of the Collection<T>.
protected override void RemoveItem(int index)
Parameters
indexintThe zero-based index of the element to remove.
Exceptions
- ArgumentOutOfRangeException
<code class="paramref">index</code> is less than zero.-or-
indexis equal to or greater than Count.
SetItem(int, TCollected)
Replaces the element at the specified index.
protected override void SetItem(int index, TCollected item)
Parameters
indexintThe zero-based index of the element to replace.
itemTCollectedThe new value for the element at the specified index. The value can be null for reference types.
Exceptions
- ArgumentOutOfRangeException
<code class="paramref">index</code> is less than zero.-or-
indexis greater than Count.
SetOpposite(TCollected, TParent)
Sets the opposite of the given item
protected abstract void SetOpposite(TCollected item, TParent newParent)
Parameters
itemTCollectedthe item
newParentTParentthe new parent or null, if the item is removed from the collection