Show / Hide Table of Contents

Interface ITypeDictionary<T>

A dictionary that can store objects, and indexes them by their type.

Inherited Members
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Type, T>>.GetEnumerator()
System.Collections.IEnumerable.GetEnumerator()
ICloneable.Clone()
ICloneable.CopyFrom(ICloneable)
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 key is null.

System.Collections.Generic.KeyNotFoundException

Thrown if key was not found.

AmbiguousTypeException

If there are multiple values of type key.

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 value is null.

System.ArgumentException

Thrown if a value of type V was already added.

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

true if the dictionary contains one ore more values of the specified type; otherwise, false.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if key is null.

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

true if the dictionary contains the specified value; otherwise, false.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if value is null.

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 TResult could not be found.

AmbiguousTypeException

If there are multiple values of type TResult.

Remove(T)

Removes the specified value.

Declaration
bool Remove(T value)
Parameters
Type Name Description
T value

The value.

Returns
Type Description
System.Boolean

true if the value was removed; otherwise false.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if value is null.

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

true if the value was resolved; otherwise false.

Exceptions
Type Condition
AmbiguousTypeException

If there are multiple values of type key.

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

true if the specified key contains the type; otherwise false.

Type Parameters
Name Description
TResult

The type of the result.

Exceptions
Type Condition
AmbiguousTypeException

If the value could not be uniquely determined.

Extension Methods

Utility.ThrowIfNull<T>(T, String)
Back to top Generated by DocFX