Class GorgonBaseNamedObjectDictionary<T>
Base dictionary for Gorgon library named objects.
Inheritance
Inherited Members
Namespace: Gorgon.Collections
Assembly: Gorgon.Core.dll
Syntax
public abstract class GorgonBaseNamedObjectDictionary<T> : IGorgonNamedObjectDictionary<T>, ICollection<T>, IGorgonNamedObjectReadOnlyDictionary<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : IGorgonNamedObject
Type Parameters
Name | Description |
---|---|
T | Type of object, must implement IGorgonNamedObject. |
Remarks
This is a base class used to help in the creation of custom dictionaries that store objects that implement the IGorgonNamedObject interface.
Constructors
| Edit this page View SourceGorgonBaseNamedObjectDictionary(bool)
Initializes a new instance of the GorgonBaseNamedObjectDictionary<T> class.
Declaration
protected GorgonBaseNamedObjectDictionary(bool caseSensitive)
Parameters
Type | Name | Description |
---|---|---|
bool | caseSensitive | true if the key names are case sensitive, false if not. |
Properties
| Edit this page View SourceCount
Gets the number of elements contained in the dictionary.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Items
Property to return the list of items in the underlying collection.
Declaration
protected IDictionary<string, T> Items { get; }
Property Value
Type | Description |
---|---|
IDictionary<string, T> |
KeysAreCaseSensitive
Property to return whether the keys are case sensitive.
Declaration
public bool KeysAreCaseSensitive { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceAddItems(IEnumerable<T>)
Function to add several items to the list.
Declaration
protected void AddItems(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | IEnumerable containing the items to copy. |
Contains(string)
Function to return whether an item with the specified name exists in this collection.
Declaration
public bool Contains(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the item to find. |
Returns
Type | Description |
---|---|
bool | true if found, false if not. |
Contains(T)
Function to return whether the specified object exists in the collection.
Declaration
public bool Contains(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to find. |
Returns
Type | Description |
---|---|
bool | true if found, false if not. |
CopyTo(T[], int)
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The one-dimensional Array that is the destination of the elements copied from dictionary. The Array must have zero-based indexing. |
int | arrayIndex | The zero-based index in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
ArgumentException |
-or-
|
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public virtual IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> | A IEnumerator<T> that can be used to iterate through the collection. |
RemoveItem(T)
Function to remove an item from the collection.
Declaration
protected void RemoveItem(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to remove. |
TryGetValue(string, out T)
Function to return an item from the collection.
Declaration
public bool TryGetValue(string name, out T value)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the item to look up. |
T | value | The item, if found, or the default value for the type if not. |
Returns
Type | Description |
---|---|
bool | true if the item was found, false if not. |
UpdateItem(string, T)
Function to update an item in the list by its name, and optionally, rename the key for that item if necessary.
Declaration
protected void UpdateItem(string name, T value)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the object to set. |
T | value | Value to set to the item. |
Remarks
If the item in value
has a different name than the name provided, then the object with the name specified will be
removed, and the new item will be added. This allows the collection to rename the key for an item should its name change.