Class ModelCollection
- Namespace
- NMF.Models.Repository
- Assembly
- NMF.Models.dll
Denotes a collection of models
public class ModelCollection : IDictionary<Uri, Model>, ICollection<KeyValuePair<Uri, Model>>, IEnumerable<KeyValuePair<Uri, Model>>, IEnumerable
- Inheritance
-
ModelCollection
- Implements
- Derived
- Inherited Members
Constructors
ModelCollection(IModelRepository)
Creates a new instance
public ModelCollection(IModelRepository repo)
Parameters
repoIModelRepositorythe parent repository
Properties
AllowOverride
true, if elements in the model collection may be overridden, otherwise false
protected virtual bool AllowOverride { get; }
Property Value
Count
Gets the number of elements contained in the ICollection<T>.
public int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
IsReadOnly
Gets a value indicating whether the ICollection<T> is read-only.
public bool IsReadOnly { get; }
Property Value
- bool
true if the ICollection<T> is read-only; otherwise, false.
this[Uri]
Gets or sets the element with the specified key.
public Model this[Uri key] { get; set; }
Parameters
keyUriThe key of the element to get or set.
Property Value
- Model
The element with the specified key.
Exceptions
- ArgumentNullException
keyis null.- KeyNotFoundException
The property is retrieved and
keyis not found.- NotSupportedException
The property is set and the IDictionary<TKey, TValue> is read-only.
Keys
Gets an ICollection<T> containing the keys of the IDictionary<TKey, TValue>.
public ICollection<Uri> Keys { get; }
Property Value
- ICollection<Uri>
An ICollection<T> containing the keys of the object that implements IDictionary<TKey, TValue>.
Repository
Gets the parent repository
public IModelRepository Repository { get; }
Property Value
Values
Gets an ICollection<T> containing the values in the IDictionary<TKey, TValue>.
public ICollection<Model> Values { get; }
Property Value
- ICollection<Model>
An ICollection<T> containing the values in the object that implements IDictionary<TKey, TValue>.
Methods
Add(KeyValuePair<Uri, Model>)
Adds an item to the ICollection<T>.
public void Add(KeyValuePair<Uri, Model> item)
Parameters
itemKeyValuePair<Uri, Model>The object to add to the ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Add(Uri, Model)
Adds an element with the provided key and value to the IDictionary<TKey, TValue>.
public virtual void Add(Uri key, Model value)
Parameters
keyUriThe object to use as the key of the element to add.
valueModelThe object to use as the value of the element to add.
Exceptions
- ArgumentNullException
keyis null.- ArgumentException
An element with the same key already exists in the IDictionary<TKey, TValue>.
- NotSupportedException
The IDictionary<TKey, TValue> is read-only.
Clear()
Removes all items from the ICollection<T>.
public void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Contains(KeyValuePair<Uri, Model>)
Determines whether the ICollection<T> contains a specific value.
public bool Contains(KeyValuePair<Uri, Model> item)
Parameters
itemKeyValuePair<Uri, Model>The object to locate in the ICollection<T>.
Returns
- bool
true if
itemis found in the ICollection<T>; otherwise, false.
ContainsKey(Uri)
Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.
public bool ContainsKey(Uri key)
Parameters
keyUriThe key to locate in the IDictionary<TKey, TValue>.
Returns
- bool
true if the IDictionary<TKey, TValue> contains an element with the key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.
CopyTo(KeyValuePair<Uri, Model>[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
public void CopyTo(KeyValuePair<Uri, Model>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<Uri, Model>[]The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.
arrayIndexintThe zero-based index in
arrayat which copying begins.
Exceptions
- ArgumentNullException
arrayis null.- ArgumentOutOfRangeException
arrayIndexis less than 0.- ArgumentException
The number of elements in the source ICollection<T> is greater than the available space from
arrayIndexto the end of the destinationarray.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<Uri, Model>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<Uri, Model>>
An enumerator that can be used to iterate through the collection.
Remove(KeyValuePair<Uri, Model>)
Removes the first occurrence of a specific object from the ICollection<T>.
public bool Remove(KeyValuePair<Uri, Model> item)
Parameters
itemKeyValuePair<Uri, Model>The 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.
Remove(Uri)
Removes the element with the specified key from the IDictionary<TKey, TValue>.
public bool Remove(Uri key)
Parameters
keyUriThe key of the element to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false. This method also returns false if
keywas not found in the original IDictionary<TKey, TValue>.
Exceptions
- ArgumentNullException
keyis null.- NotSupportedException
The IDictionary<TKey, TValue> is read-only.
TryGetValue(Uri, out Model)
Gets the value associated with the specified key.
public bool TryGetValue(Uri key, out Model value)
Parameters
keyUriThe key whose value to get.
valueModelWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
valueparameter. This parameter is passed uninitialized.
Returns
- bool
true if the object that implements IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.