Gorgon
Show / Hide Table of Contents

Class GorgonBaseNamedObjectList<T>

Base list type for Gorgon library named objects.

Inheritance
object
GorgonBaseNamedObjectList<T>
GorgonNamedObjectList<T>
Implements
IGorgonNamedObjectList<T>
IList<T>
ICollection<T>
IGorgonNamedObjectReadOnlyList<T>
IReadOnlyList<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 GorgonBaseNamedObjectList<T> : IGorgonNamedObjectList<T>, IList<T>, ICollection<T>, IGorgonNamedObjectReadOnlyList<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : IGorgonNamedObject
Type Parameters
Name Description
T

The type of object to store in the collection. Must implement the IGorgonNamedObject interface.

Remarks

This is a base class used to help in the creation of custom lists that store objects that implement the IGorgonNamedObject interface.

Constructors

| Edit this page View Source

GorgonBaseNamedObjectList(bool)

Initializes a new instance of the GorgonBaseNamedObjectList<T> class.

Declaration
protected GorgonBaseNamedObjectList(bool caseSensitive)
Parameters
Type Name Description
bool caseSensitive

true to use case sensitive keys, false to ignore casing.

Properties

| Edit this page View Source

Count

Gets the number of elements contained in the list.

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 IList<T> Items { get; }
Property Value
Type Description
IList<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 items to the list.

Declaration
protected void AddItems(IEnumerable<T> items)
Parameters
Type Name Description
IEnumerable<T> items

List of items to add.

| 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)

Determines whether the list contains a specific value.

Declaration
public bool Contains(T item)
Parameters
Type Name Description
T item

The object to locate in the list.

Returns
Type Description
bool

true if item is found in the list; otherwise, false.

| Edit this page View Source

CopyTo(T[], int)

Copies the elements of the list 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 list. The Array must have zero-based indexing.

int arrayIndex

The zero-based index in array at which copying begins.

Exceptions
Type Condition
ArgumentNullException

array is 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 list 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 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

GetItemByName(string)

Function to retrieve the item at the specified index by name.

Declaration
protected T GetItemByName(string name)
Parameters
Type Name Description
string name

Name of the object to find.

Returns
Type Description
T

The object with the specified name.

Exceptions
Type Condition
KeyNotFoundException

Thrown when no object with the specified name was found in the collection.

| Edit this page View Source

IndexOf(string)

Determines the index of a specific item in the list.

Declaration
public int IndexOf(string name)
Parameters
Type Name Description
string name

Name of the item to find.

Returns
Type Description
int

The index of name if found in the list; otherwise, -1.

| Edit this page View Source

IndexOf(T)

Determines the index of a specific item in the list.

Declaration
public int IndexOf(T item)
Parameters
Type Name Description
T item

The object to locate in the list.

Returns
Type Description
int

The index of item if found in the list; otherwise, -1.

| Edit this page View Source

InsertItems(int, IEnumerable<T>)

Function to insert items into the list at a given index.

Declaration
protected void InsertItems(int index, IEnumerable<T> items)
Parameters
Type Name Description
int index

Index to insert at.

IEnumerable<T> items

Items to add.

| Edit this page View Source

RemoveItemByName(string)

Function to remove an item from the list by its name.

Declaration
protected void RemoveItemByName(string name)
Parameters
Type Name Description
string name

Name of the item to remove.

Implements

IGorgonNamedObjectList<T>
IList<T>
ICollection<T>
IGorgonNamedObjectReadOnlyList<T>
IReadOnlyList<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>>)
GorgonIReadOnlyListExtensions.Contains<T>(IReadOnlyList<T>, T)
GorgonIReadOnlyListExtensions.CopyTo<T>(IReadOnlyList<T>, T[])
GorgonIReadOnlyListExtensions.FirstIndexOf<T>(IReadOnlyList<T>, Predicate<T>)
GorgonIReadOnlyListExtensions.IndexOf<T>(IReadOnlyList<T>, T)
GorgonIReadOnlyListExtensions.LastIndexOf<T>(IReadOnlyList<T>, Predicate<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