public JsonDictionaryContract(Type underlyingType)
: base(underlyingType)
{
Type keyType;
Type valueType;
if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IDictionary<,>), out _genericCollectionDefinitionType))
{
keyType = _genericCollectionDefinitionType.GetGenericArguments()[0];
valueType = _genericCollectionDefinitionType.GetGenericArguments()[1];
}
else
{
ReflectionUtils.GetDictionaryKeyValueTypes(UnderlyingType, out keyType, out valueType);
}
DictionaryKeyType = keyType;
DictionaryValueType = valueType;
if (IsTypeGenericDictionaryInterface(UnderlyingType))
{
CreatedType = ReflectionUtils.MakeGenericType(typeof(Dictionary<,>), keyType, valueType);
}
else
{
CreatedType = underlyingType;
}
}