Class ConvertibleConverterDictionary
- Namespace
- Cuemon
- Assembly
- Cuemon.Kernel.dll
Represents a collection of converters that map IConvertible implementations to byte arrays.
public class ConvertibleConverterDictionary : IReadOnlyDictionary<Type, Func<IConvertible, byte[]>>, IReadOnlyCollection<KeyValuePair<Type, Func<IConvertible, byte[]>>>, IEnumerable<KeyValuePair<Type, Func<IConvertible, byte[]>>>, IEnumerable
- Inheritance
-
ConvertibleConverterDictionary
- Implements
Properties
Count
Gets the number of converters contained in this instance.
public int Count { get; }
Property Value
- int
The number of registered converters.
this[Type]
Gets the converter associated with the specified type.
public Func<IConvertible, byte[]> this[Type type] { get; }
Parameters
typeTypeThe type whose associated converter to retrieve.
Property Value
- Func<IConvertible, byte[]>
The converter associated with
type, or null if no converter is registered for the specified type.
Keys
Gets the collection of types for which converters are registered.
public IEnumerable<Type> Keys { get; }
Property Value
- IEnumerable<Type>
A collection that contains the registered converter types.
Values
Gets the collection of registered converters.
public IEnumerable<Func<IConvertible, byte[]>> Values { get; }
Property Value
- IEnumerable<Func<IConvertible, byte[]>>
A collection that contains the registered converters.
Methods
Add(Type, Func<IConvertible, byte[]>)
Adds a converter for the specified type.
public ConvertibleConverterDictionary Add(Type type, Func<IConvertible, byte[]> converter)
Parameters
typeTypeThe type that implements IConvertible.
converterFunc<IConvertible, byte[]>The delegate that converts an IConvertible instance to a byte array.
Returns
- ConvertibleConverterDictionary
This instance so that additional converters can be configured.
Exceptions
- ArgumentNullException
typeis null.- ArgumentOutOfRangeException
typedoes not implement IConvertible.
Add<T>(Func<T, byte[]>)
Adds a converter for the specified T.
public ConvertibleConverterDictionary Add<T>(Func<T, byte[]> converter) where T : IConvertible
Parameters
Returns
- ConvertibleConverterDictionary
This instance so that additional converters can be configured.
Type Parameters
TThe type that implements IConvertible.
Exceptions
- TypeArgumentOutOfRangeException
Tdoes not implement IConvertible.
ContainsKey(Type)
Determines whether this dictionary contains a converter for the specified key.
public bool ContainsKey(Type key)
Parameters
keyTypeThe type to locate.
Returns
GetEnumerator()
Returns an enumerator that iterates through the registered converters.
public IEnumerator<KeyValuePair<Type, Func<IConvertible, byte[]>>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<Type, Func<IConvertible, byte[]>>>
An enumerator that can be used to iterate through the registered converters.
TryGetValue(Type, out Func<IConvertible, byte[]>)
Gets the converter associated with the specified key.
public bool TryGetValue(Type key, out Func<IConvertible, byte[]> value)
Parameters
keyTypeThe type whose associated converter to retrieve.
valueFunc<IConvertible, byte[]>When this method returns, contains the converter associated with the specified
key, if the key is found; otherwise, the default value for the type of thevalueparameter.
Returns
Exceptions
- ArgumentNullException
keyis null.