Interface ITypeDictionary<T>
A dictionary that can store objects, and indexes them by their type.
Inherited Members
Namespace: SpiceSharp
Assembly: SpiceSharp.dll
Syntax
public interface ITypeDictionary<T> : IEnumerable<KeyValuePair<Type, T>>, IEnumerable, ICloneable
Type Parameters
| Name | Description |
|---|---|
| T | The common base type of all objects. |
Properties
Count
Gets the number of elements contained in the ITypeDictionary<T>.
Declaration
int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The count. |
Item[Type]
Gets the value with the specified key.
Declaration
T this[Type key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | key | The key. |
Property Value
| Type | Description |
|---|---|
| T | The key type. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
| System.Collections.Generic.KeyNotFoundException | Thrown if |
| AmbiguousTypeException | If there are multiple values of type |
Keys
Gets the keys.
Declaration
IEnumerable<Type> Keys { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.Type> | The keys. |
Values
Gets the values.
Declaration
IEnumerable<T> Values { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> | The values. |
Methods
Add<V>(V)
Adds the specified value to the dictionary.
Declaration
void Add<V>(V value)
where V : T
Parameters
| Type | Name | Description |
|---|---|---|
| V | value | The value. |
Type Parameters
| Name | Description |
|---|---|
| V | The value type. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
| System.ArgumentException | Thrown if a value of type |
Clear()
Clears all items in the dictionary.
Declaration
void Clear()
ContainsKey(Type)
Determines whether the dictionary contains one or more values of the specified type.
Declaration
bool ContainsKey(Type key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | key | The key. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
ContainsValue(T)
Determines whether the dictionary contains the specified value.
Declaration
bool ContainsValue(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
GetAllValues<TResult>()
Gets all strongly typed values from the dictionary.
Declaration
IEnumerable<TResult> GetAllValues<TResult>()
where TResult : T
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<TResult> | The results. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result. |
GetValue<TResult>()
Gets the strongly typed value from the dictionary.
Declaration
TResult GetValue<TResult>()
where TResult : T
Returns
| Type | Description |
|---|---|
| TResult | The result. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result. |
Exceptions
| Type | Condition |
|---|---|
| TypeNotFoundException | Thrown if a value of type |
| AmbiguousTypeException | If there are multiple values of type |
Remove(T)
Removes the specified value.
Declaration
bool Remove(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
TryGetValue(Type, out T)
Tries to get a value from the dictionary.
Declaration
bool TryGetValue(Type key, out T value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | key | The key type. |
| T | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| AmbiguousTypeException | If there are multiple values of type |
TryGetValue<TResult>(out TResult)
Tries to get a strongly typed value from the dictionary.
Declaration
bool TryGetValue<TResult>(out TResult value)
where TResult : T
Parameters
| Type | Name | Description |
|---|---|---|
| TResult | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result. |
Exceptions
| Type | Condition |
|---|---|
| AmbiguousTypeException | If the value could not be uniquely determined. |