Gorgon
Show / Hide Table of Contents

Class GorgonBaseNamedObjectDictionary<T>

Base dictionary for Gorgon library named objects.

Inheritance
object
GorgonBaseNamedObjectDictionary<T>
GorgonNamedObjectDictionary<T>
GorgonFileExtensionCollection
Implements
IGorgonNamedObjectDictionary<T>
ICollection<T>
IGorgonNamedObjectReadOnlyDictionary<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
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 Source

GorgonBaseNamedObjectDictionary(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 Source

Count

Gets the number of elements contained in the dictionary.

Declaration
public int Count { get; }
Property Value
Type Description
int
| Edit this page View Source

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>
| Edit this page View Source

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 Source

AddItems(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

CopyTo(T[], int)

Copies the elements of the dictionary to an Array, starting at a particular Array index.

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 array at which copying begins.

Exceptions
Type Condition
ArgumentNullException

array == null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException
<code class="paramref">array</code> is multidimensional.

-or- arrayIndex is equal to or greater than the length of array. -or- The number of elements in the source dictionary is greater than the available space from arrayIndex to the end of the destination array. -or- Type array cannot be cast automatically to the type of the destination array.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

Implements

IGorgonNamedObjectDictionary<T>
ICollection<T>
IGorgonNamedObjectReadOnlyDictionary<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonTreeLinqExtensions.TraverseDepthFirst<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
GorgonTreeLinqExtensions.Traverse<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author