Interface IDictionaryTypeShape<TDictionary, TKey, TValue>
- Namespace
- PolyType.Abstractions
- Assembly
- PolyType.dll
Provides a strongly typed shape model for a .NET type that is a dictionary.
public interface IDictionaryTypeShape<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
Gets 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
Gets 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
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.
GetInserter(DictionaryInsertionMode)
Creates a delegate used for inserting a new key/value pair to a mutable dictionary.
DictionaryInserter<TDictionary, TKey, TValue> GetInserter(DictionaryInsertionMode insertionMode = DictionaryInsertionMode.None)
Parameters
insertionMode
DictionaryInsertionModeSpecifies the duplicate key handling strategy used by the delegate.
Returns
- DictionaryInserter<TDictionary, TKey, TValue>
A delegate used for inserting entries into a mutable dictionary.
Exceptions
- InvalidOperationException
The collection is not Mutable.
GetMutableConstructor()
Creates a delegate for creating an empty, mutable collection.
MutableCollectionConstructor<TKey, TDictionary> GetMutableConstructor()
Returns
- MutableCollectionConstructor<TKey, TDictionary>
A delegate for creating an empty mutable collection.
Exceptions
- InvalidOperationException
The collection is not Mutable.
GetParameterizedConstructor()
Creates a delegate for creating a collection from a span.
ParameterizedCollectionConstructor<TKey, KeyValuePair<TKey, TValue>, TDictionary> GetParameterizedConstructor()
Returns
- ParameterizedCollectionConstructor<TKey, KeyValuePair<TKey, TValue>, TDictionary>
A delegate constructing a collection from a span of values.
Exceptions
- InvalidOperationException
The collection is not Parameterized.