public ListDocumentInfo(Type implementingType) { if (implementingType.IsGenericType) { _listValueType = implementingType.GetGenericArguments()[0]; _documentFieldInfo = new DocumentFieldInfo(_listValueType); _listAdapterFactoryType = ListAdapterFactoryType.Generic; _creatorType = _type.IsInterface || _type.IsArray ? CreatorType.SpecifiedTypeList : CreatorType.SpecifiedType; } else { _listValueType = typeof(object); _documentFieldInfo = new DocumentFieldInfo(_listValueType); _listAdapterFactoryType = ListAdapterFactoryType.NonGeneric; _creatorType = _type.IsInterface || _type.IsArray ? CreatorType.ObjectList : CreatorType.SpecifiedType; } }
public DictionaryDocumentInfo() { if (_type.TryGetImplementingGenericType(out var dictionaryType, typeof(IDictionary <,>)) || _type.TryGetImplementingGenericType(out dictionaryType, typeof(IReadOnlyDictionary <,>))) { var arguments = dictionaryType.GetGenericArguments(); _dictionaryKeyType = arguments[0]; _dictionaryValueType = arguments[1]; _documentFieldInfo = new DocumentFieldInfo(_dictionaryValueType); if (_type == dictionaryType) { _creatorType = CreatorType.SpecifiedTypeDictionary; _dictionaryAdapterFactoryType = DictionaryAdapterFactoryType.NonGeneric; } else { _creatorType = CreatorType.SpecifiedType; _dictionaryAdapterFactoryType = DictionaryAdapterFactoryType.Generic; } }
public DictionaryDocumentInfo(Type implementingType) { if (implementingType.IsGenericType) { var arguments = implementingType.GetGenericArguments(); _dictionaryKeyType = arguments[0]; _dictionaryValueType = arguments[1]; _documentFieldInfo = new DocumentFieldInfo(_dictionaryValueType); _dictionaryAdapterFactoryType = DictionaryAdapterFactoryType.Generic; _creatorType = _type.IsInterface ? CreatorType.SpecifiedTypeDictionary : CreatorType.SpecifiedType; } else { _dictionaryKeyType = typeof(string); _dictionaryValueType = typeof(object); _documentFieldInfo = new DocumentFieldInfo(_dictionaryValueType); _dictionaryAdapterFactoryType = DictionaryAdapterFactoryType.NonGeneric; _creatorType = _type.IsInterface ? CreatorType.ObjectDictionary : CreatorType.SpecifiedType; } }
public ListDocumentInfo() { if (_type.TryGetImplementingGenericType(out var listType, typeof(IList <>)) || _type.TryGetImplementingGenericType(out listType, typeof(IReadOnlyList <>))) { _listValueType = listType.GetGenericArguments()[0]; _documentFieldInfo = new DocumentFieldInfo(_listValueType); if (_type == listType) { _creatorType = CreatorType.SpecifiedTypeList; _listAdapterFactoryType = ListAdapterFactoryType.NonGeneric; } else if (_type.IsArray) { _creatorType = CreatorType.SpecifiedTypeList; _listAdapterFactoryType = ListAdapterFactoryType.Generic; } else { _creatorType = CreatorType.SpecifiedType; _listAdapterFactoryType = ListAdapterFactoryType.Generic; } }