Table of Contents

Class NamedCollection<T>

Namespace
NanoByte.Common.Collections
Assembly
NanoByte.Common.dll

A keyed collection (pseudo-dictionary) of INamed objects. Case-insensitive!

public class NamedCollection<T> : KeyedCollection<string, T>, IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : INamed

Type Parameters

T
Inheritance
object
NamedCollection<T>
Implements
Derived
Inherited Members
Extension Methods

Remarks

Elements are automatically maintained in an alphabetically sorted order. Suitable for XML serialization.

Constructors

NamedCollection()

A keyed collection (pseudo-dictionary) of INamed objects. Case-insensitive!

public NamedCollection()

Remarks

Elements are automatically maintained in an alphabetically sorted order. Suitable for XML serialization.

NamedCollection(IEnumerable<T>)

Creates a new named collection pre-filled with elements.

public NamedCollection(IEnumerable<T> elements)

Parameters

elements IEnumerable<T>

The elements to pre-fill the collection with. Must all have unique Names!

Methods

ClearItems()

protected override void ClearItems()

GetKeyForItem(T)

protected override string GetKeyForItem(T item)

Parameters

item T

Returns

string

InsertItem(int, T)

protected override void InsertItem(int index, T item)

Parameters

index int
item T

RemoveItem(int)

protected override void RemoveItem(int index)

Parameters

index int

Rename(T, string)

Renames an element in the list. Renaming an element in the list directly (without using this method) will prevent lookups from working properly!

public void Rename(T element, string newName)

Parameters

element T

The element to rename.

newName string

The new Name for the element.

Exceptions

KeyNotFoundException

The element is not in the collection.

InvalidOperationException

The newName is already taken by another element in the collection.

SetItem(int, T)

protected override void SetItem(int index, T item)

Parameters

index int
item T

Events

CollectionChanged

public event Action<object>? CollectionChanged

Event Type

Action<object>