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
TParentthe type of the parent
TCollectedthe 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
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
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
itemTCollectedThe 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
itemTCollectedThe object to remove from the ICollection<T>.
Returns
- bool
true if
itemwas successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitemis 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
itemTCollectedthe item
newParentTParentthe new parent or null, if the item is removed from the collection