Class NamedCollection<T>
A keyed collection (pseudo-dictionary) of INamed objects. Case-insensitive!
Implements
Namespace: NanoByte.Common.Collections
Assembly: NanoByte.Common.dll
Syntax
public class NamedCollection<T> : KeyedCollection<string, T>, ICloneable<NamedCollection<T>> where T : INamed
Type Parameters
Name | Description |
---|---|
T |
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!
Declaration
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.
Declaration
public NamedCollection(IEnumerable<T> elements)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | elements | The elements to pre-fill the collection with. Must all have unique Names! |
Methods
ClearItems()
Declaration
protected override void ClearItems()
Clone()
Creates a shallow copy of this collection (elements are not cloned).
Declaration
public virtual NamedCollection<T> Clone()
Returns
Type | Description |
---|---|
NamedCollection<T> | The cloned collection. |
GetKeyForItem(T)
Declaration
protected override string GetKeyForItem(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
System.String |
InsertItem(Int32, T)
Declaration
protected override void InsertItem(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | |
T | item |
RemoveItem(Int32)
Declaration
protected override void RemoveItem(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
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!
Declaration
public void Rename(T element, string newName)
Parameters
Type | Name | Description |
---|---|---|
T | element | The element to rename. |
System.String | newName | The new Name for the element. |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | The |
InvalidOperationException | The |
SetItem(Int32, T)
Declaration
protected override void SetItem(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | |
T | item |
Events
CollectionChanged
Declaration
public event Action<object> CollectionChanged
Event Type
Type | Description |
---|---|
Action<Object> |