Class TypeDictionary<T>
An implementation of the ITypeDictionary<T> interface. This implementation supports multithreaded access.
Inheritance
Implements
Inherited Members
Namespace: SpiceSharp.General
Assembly: SpiceSharp.dll
Syntax
public class TypeDictionary<T> : ITypeDictionary<T>, IEnumerable<KeyValuePair<Type, T>>, IEnumerable, ICloneable
Type Parameters
| Name | Description |
|---|---|
| T | The base type. |
Constructors
TypeDictionary()
Initializes a new instance of the TypeDictionary<T> class.
Declaration
public TypeDictionary()
Properties
Count
Gets the number of elements contained in the ITypeDictionary<T>.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The count. |
Item[Type]
Gets the value with the specified key.
Declaration
public 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
public IEnumerable<Type> Keys { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.Type> | The keys. |
Values
Gets the values.
Declaration
public 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
public 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()
Removes all items from the TypeDictionary<T>.
Declaration
public void Clear()
Clone()
Clones the instance.
Declaration
protected virtual ICloneable Clone()
Returns
| Type | Description |
|---|---|
| ICloneable | The cloned instance. |
ContainsKey(Type)
Determines whether the dictionary contains one or more values of the specified type.
Declaration
public 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
public bool ContainsValue(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
CopyFrom(ICloneable)
Copies the contents of one interface to this one.
Declaration
protected virtual void CopyFrom(ICloneable source)
Parameters
| Type | Name | Description |
|---|---|---|
| ICloneable | source | The source parameter. |
GetAllValues<TResult>()
Gets all strongly typed values from the dictionary.
Declaration
public 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. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<Type, T>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.Type, T>> | An enumerator that can be used to iterate through the collection. |
GetValue<TResult>()
Gets the strongly typed value from the dictionary.
Declaration
public 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
public bool Remove(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
Remove(Type)
Removes the value of the specified type from the dictionary.
Declaration
public bool Remove(Type key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | key | The key. |
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
public 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
public 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. |
Explicit Interface Implementations
ICloneable.Clone()
Declaration
ICloneable ICloneable.Clone()
Returns
| Type | Description |
|---|---|
| ICloneable |
ICloneable.CopyFrom(ICloneable)
Declaration
void ICloneable.CopyFrom(ICloneable source)
Parameters
| Type | Name | Description |
|---|---|---|
| ICloneable | source |
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |