Class ComponentCollection<T>
Implements a collection of components.
Each component in the collection may be given a unique name for later retrieval.
Namespace: EmbedIO.Utilities
Syntax
public class ComponentCollection<T> : ConfiguredObject, IComponentCollection<T>, IReadOnlyList<T>
Type Parameters
| Name | Description |
|---|---|
| T | The type of components in the collection. |
Properties
Count
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Item[Int32]
Declaration
public T this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index |
Property Value
| Type | Description |
|---|---|
| T |
Item[String]
Gets the component with the specified name.
Declaration
public T this[string key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| String | key |
Property Value
| Type | Description |
|---|---|
| T | The component. |
Named
Gets an
Declaration
public IReadOnlyDictionary<string, T> Named { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<String, T> | The named components. |
WithSafeNames
Gets an
The safe name of a component is never null. If a component's unique name if null, its safe name will be some non-null string somehow identifying it.
Note that safe names are not necessarily unique.
Declaration
public IReadOnlyList<(string SafeName, T Component)> WithSafeNames { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValueTuple<String, T>> | A list of |
Methods
Add(String, T)
Adds a component to the collection,
giving it the specified name if it is not null.
Declaration
public void Add(string name, T component)
Parameters
| Type | Name | Description |
|---|---|---|
| String | name | The name given to the module, or null. |
| T | component | The component. |
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<T> |
Lock()
Locks the collection, preventing further additions.
Declaration
public void Lock()