Class EntityCollection<T>
- Namespace
- Loehnert.TypeAndResult
- Assembly
- Loehnert.TypeAndResult.dll
KeyItemCollection for EntityBase objects. Add overrides existing keys.
public class EntityCollection<T> : KeyItemCollection<T>, IKeyItemCollection<T>, IList<T>, ICollection<T>, IEnumerable<T>, INotifyCollectionChanged, IList, ICollection, IEnumerable, INotifyPropertyChanged where T : EntityBase, IHasKey
Type Parameters
T
The type of the elements in the collection.
- Inheritance
-
EntityCollection<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- Inherited Members
Constructors
EntityCollection()
Initializes a new instance of the EntityCollection<T> class.
public EntityCollection()
EntityCollection(string)
Initializes a new instance of the EntityCollection<T> class.
public EntityCollection(string collectionItemDescription)
Parameters
collectionItemDescription
stringA short phrase for a collection item. E. g. 'User'.
Exceptions
- ArgumentNullException
Thrown when
collectionItemDescription
is null or empty.
EntityCollection(string, IEnumerable<T>)
Initializes a new instance of the EntityCollection<T> class.
public EntityCollection(string collectionItemDescription, IEnumerable<T> items)
Parameters
collectionItemDescription
stringA short phrase for a collection item. E. g. 'User'.
items
IEnumerable<T>These items will be added to the collection.
Exceptions
- ArgumentNullException
Thrown when
collectionItemDescription
oritems
is null.
Methods
Add(T)
Adds an object to the end of the ICollection<T> and replaces an object with the same key.
public override void Add(T item)
Parameters
item
TThe object to be added.
Exceptions
- ArgumentNullException
Thrown when
item
is null oritem.key.key
is null, empty or whitespace.
AddRange(IEnumerable<T>)
Adds a range object to the end of the ICollection<T> and replaces objects with the same keys.
public override void AddRange(IEnumerable<T> items)
Parameters
items
IEnumerable<T>The object to be added.
Exceptions
- ArgumentNullException
Thrown when any
items.key.key
is null, empty or whitespace, oritems
is null.
Contains(T)
Determines whether an element is in the ICollection<T>.
public override bool Contains(T item)
Parameters
item
TThe object to locate in the ICollection<T>.
Returns
- bool
True if item is found.