Table of Contents

Interface IDictionaryShape<TDictionary, TKey, TValue>

Namespace
TypeShape.Abstractions
Assembly
TypeShape.dll

Provides a strongly typed shape model for a .NET type that is a dictionary.

public interface IDictionaryShape<TDictionary, TKey, TValue> : ITypeShape<TDictionary>, IDictionaryTypeShape, ITypeShape where TKey : notnull

Type Parameters

TDictionary

The type of the underlying dictionary.

TKey

The type of the underlying key.

TValue

The type of the underlying value.

Inherited Members

Remarks

Typically covers types implementing interfaces such as IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue> or IDictionary.

Properties

KeyType

The shape of the underlying key type.

ITypeShape<TKey> KeyType { get; }

Property Value

ITypeShape<TKey>

Remarks

For non-generic dictionaries this returns the shape for object.

ValueType

The shape of the underlying value type.

ITypeShape<TValue> ValueType { get; }

Property Value

ITypeShape<TValue>

Remarks

For non-generic dictionaries this returns the shape for object.

Methods

GetAddKeyValuePair()

Creates a setter delegate used for appending a KeyValuePair<TKey, TValue> to a mutable dictionary.

Setter<TDictionary, KeyValuePair<TKey, TValue>> GetAddKeyValuePair()

Returns

Setter<TDictionary, KeyValuePair<TKey, TValue>>

A setter delegate used for appending entries to a mutable dictionary.

Exceptions

InvalidOperationException

The collection is not Mutable.

GetDefaultConstructor()

Creates a delegate wrapping a parameterless constructor of a mutable collection.

Func<TDictionary> GetDefaultConstructor()

Returns

Func<TDictionary>

A delegate wrapping a default constructor.

Exceptions

InvalidOperationException

The collection is not Mutable.

GetEnumerableConstructor()

Creates a constructor delegate for creating a collection from an enumerable.

Func<IEnumerable<KeyValuePair<TKey, TValue>>, TDictionary> GetEnumerableConstructor()

Returns

Func<IEnumerable<KeyValuePair<TKey, TValue>>, TDictionary>

A delegate constructing a collection from an enumerable of values.

Exceptions

InvalidOperationException

The collection is not Enumerable.

GetGetDictionary()

Creates a delegate used for getting a IReadOnlyDictionary<TKey, TValue> view of the dictionary.

Func<TDictionary, IReadOnlyDictionary<TKey, TValue>> GetGetDictionary()

Returns

Func<TDictionary, IReadOnlyDictionary<TKey, TValue>>

A delegate accepting a TDictionary and returning an IReadOnlyDictionary<TKey, TValue> view of the instance.

GetSpanConstructor()

Creates a constructor delegate for creating a collection from a span.

SpanConstructor<KeyValuePair<TKey, TValue>, TDictionary> GetSpanConstructor()

Returns

SpanConstructor<KeyValuePair<TKey, TValue>, TDictionary>

A delegate constructing a collection from a span of values.

Exceptions

InvalidOperationException

The collection is not Span.