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
-
objectCollection<T>NamedCollection<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- 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
elementsIEnumerable<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
itemT
Returns
InsertItem(int, T)
protected override void InsertItem(int index, T item)
Parameters
indexintitemT
RemoveItem(int)
protected override void RemoveItem(int index)
Parameters
indexint
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
Exceptions
- KeyNotFoundException
The
elementis not in the collection.- InvalidOperationException
The
newNameis already taken by another element in the collection.
SetItem(int, T)
protected override void SetItem(int index, T item)
Parameters
indexintitemT
Events
CollectionChanged
public event Action<object>? CollectionChanged
Event Type
- Action<object>