Show / Hide Table of Contents

Interface ITypeDictionary<V>

A dictionary that can store instances, and indexes them by a type. This dictionary distinguishes itself by supporting for example inheritance on the type.

Namespace: SpiceSharp.General
Assembly: SpiceSharp.dll
Syntax
public interface ITypeDictionary<V>
Type Parameters
Name Description
V

The base type for values in the type dictionary.

Properties

Count

Gets the number of items in the dictionary.

Declaration
int Count { get; }
Property Value
Type Description
int

The number of items in the dictionary.

this[Type]

Gets a value from the dictionary by its type.

Declaration
V this[Type key] { get; }
Parameters
Type Name Description
Type key

The type.

Property Value
Type Description
V

The value.

Exceptions
Type Condition
ArgumentNullException

Thrown if key is null.

AmbiguousTypeException

Thrown if key does not point to a single instance.

Keys

Gets all the keys in the dictionary.

Declaration
IEnumerable<Type> Keys { get; }
Property Value
Type Description
IEnumerable<Type>

The keys in the dictionary.

Values

Gets all the values in the dictionary.

Declaration
IEnumerable<V> Values { get; }
Property Value
Type Description
IEnumerable<V>

The values in the dictionary.

Methods

Add(Type, V)

Adds a value to the dictionary.

Declaration
void Add(Type key, V value)
Parameters
Type Name Description
Type key

The key.

V value

The value.

Exceptions
Type Condition
ArgumentNullException

Thrown if key is null.

Clear()

Clears all values from the dictionary.

Declaration
void Clear()

Contains(V)

Determines whether the dictionary contains the value.

Declaration
bool Contains(V value)
Parameters
Type Name Description
V value

The value.

Returns
Type Description
bool

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

ContainsKey(Type)

Determines whether the dictionary contains a value with the specified key.

Declaration
bool ContainsKey(Type key)
Parameters
Type Name Description
Type key

The key.

Returns
Type Description
bool

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

GetAllValues(Type)

Gets all values from the dictionary that the specified key can point to.

Declaration
IEnumerable<V> GetAllValues(Type key)
Parameters
Type Name Description
Type key
Returns
Type Description
IEnumerable<V>

The values.

Exceptions
Type Condition
ArgumentNullException

Thrown if key is null.

GetValueCount(Type)

Gets the the number of values that this type points to (direct or indirect).

Declaration
int GetValueCount(Type key)
Parameters
Type Name Description
Type key

The key.

Returns
Type Description
int

The number of values.

Remove(Type, V)

Removes a value from the dictionary, but only if the value was added through the same key originally to avoid inconsistencies.

Declaration
bool Remove(Type key, V value)
Parameters
Type Name Description
Type key

The key.

V value

The value.

Returns
Type Description
bool

true if the value was remove; otherwise, false.

TryGetValue(Type, out V)

Tries to get a value from the dictionary indexed by the specified type.

Declaration
bool TryGetValue(Type key, out V value)
Parameters
Type Name Description
Type key

The key.

V value

The value.

Returns
Type Description
bool

true if the value was found; otherwise, false.

Extension Methods

Utility.ThrowIfNull<T>(T, string)
In this article
Back to top Generated by DocFX