NanoByte.Common 2.11.0
NanoByte.Common.Collections.NamedCollection< T > Class Template Reference

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

Inheritance diagram for NanoByte.Common.Collections.NamedCollection< T >:
NanoByte.Common.ICloneable< NamedCollection< T > >

Public Member Functions

 NamedCollection ()
 Creates a new named collection.
 
 NamedCollection ([InstantHandle] IEnumerable< T > elements)
 Creates a new named collection pre-filled with elements. More...
 
void Rename (T element, [Localizable(false)] string newName)
 Renames an element in the list. Renaming an element in the list directly (without using this method) will prevent lookups from working properly! More...
 
virtual NamedCollection< T > Clone ()
 Creates a shallow copy of this collection (elements are not cloned). More...
 
- Public Member Functions inherited from NanoByte.Common.ICloneable< NamedCollection< T > >
Clone ()
 Creates a new clone of this instance.
 

Protected Member Functions

override string GetKeyForItem (T item)
 
override void InsertItem (int index, T item)
 
override void SetItem (int index, T item)
 
override void RemoveItem (int index)
 
override void ClearItems ()
 

Events

Action< object >? CollectionChanged
 

Detailed Description

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

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

Type Constraints
T :INamed 

Constructor & Destructor Documentation

◆ NamedCollection()

NanoByte.Common.Collections.NamedCollection< T >.NamedCollection ( [InstantHandle] IEnumerable< T >  elements)
inline

Creates a new named collection pre-filled with elements.

Parameters
elementsThe elements to pre-fill the collection with. Must all have unique INamed.Names!

Member Function Documentation

◆ Clone()

virtual NamedCollection< T > NanoByte.Common.Collections.NamedCollection< T >.Clone ( )
virtual

Creates a shallow copy of this collection (elements are not cloned).

Returns
The cloned collection.

◆ Rename()

void NanoByte.Common.Collections.NamedCollection< T >.Rename ( element,
[Localizable(false)] string  newName 
)
inline

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

Parameters
elementThe element to rename.
newNameThe new INamed.Name for the element.
Exceptions
KeyNotFoundExceptionThe element is not in the collection.
InvalidOperationExceptionThe newName is already taken by another element in the collection.

The documentation for this class was generated from the following file: