Class OppositeSet<TParent, TCollected>
- Namespace
- NMF.Collections.ObjectModel
- Assembly
- NMF.Collections.dll
Denotes an abstract base class for a set with opposites
public abstract class OppositeSet<TParent, TCollected> : DecoratedSet<TCollected>, ISet<TCollected>, ICollection<TCollected>, IEnumerable<TCollected>, IList, ICollection, IEnumerable
Type Parameters
TParent
the type of the parent
TCollected
the type of the collection items
- Inheritance
-
DecoratedSet<TCollected>OppositeSet<TParent, TCollected>
- Implements
-
ISet<TCollected>ICollection<TCollected>IEnumerable<TCollected>
- Inherited Members
Constructors
OppositeSet(TParent)
Creates a new instance
protected OppositeSet(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
Add(TCollected)
Adds an element to the current set and returns a value to indicate if the element was successfully added.
public override bool Add(TCollected item)
Parameters
item
TCollectedThe element to add to the set.
Returns
Clear()
Removes all items from the ICollection<T>.
public override void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Remove(TCollected)
Removes the first occurrence of a specific object from the ICollection<T>.
public override bool Remove(TCollected item)
Parameters
item
TCollectedThe object to remove from the ICollection<T>.
Returns
- bool
true if
item
was successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitem
is not found in the original ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
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