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
TParent
the type of the parent element
TCollected
the 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
parent
TParentthe 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
index
intThe zero-based index at which
item
should be inserted.item
TCollectedThe object to insert. The value can be null for reference types.
Exceptions
- ArgumentOutOfRangeException
<code class="paramref">index</code> is less than zero.
-or-
index
is greater than Count.
RemoveItem(int)
Removes the element at the specified index of the Collection<T>.
protected override void RemoveItem(int index)
Parameters
index
intThe zero-based index of the element to remove.
Exceptions
- ArgumentOutOfRangeException
<code class="paramref">index</code> is less than zero.
-or-
index
is 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
index
intThe zero-based index of the element to replace.
item
TCollectedThe 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-
index
is greater than Count.
SetOpposite(TCollected, TParent)
Sets the opposite of the given item
protected abstract void SetOpposite(TCollected item, TParent newParent)
Parameters
item
TCollectedthe item
newParent
TParentthe new parent or null, if the item is removed from the collection