public static CanInstantiate ( |
||
objectType | ||
리턴 | bool |
public static bool CanInstantiate(Type objectType)
{
var objectTypeWrapper = TypeFactory.GetTypeInfo(objectType);
return
//objectType.IsPublic &&
objectTypeWrapper.IsClass &&
!objectTypeWrapper.IsInterface &&
!objectTypeWrapper.IsAbstract &&
!objectTypeWrapper.IsGenericTypeDefinition &&
!objectTypeWrapper.ContainsGenericParameters &&
objectTypeWrapper.GetConstructor(TypeFactory.EmptyTypes) != null; // parameterless constructor present?
}
public static Type GetType(MemberInfo member)
private bool TryFromMap(Type targetType, Document map, DynamoDBFlatConfig flatConfig, out object output) { output = null; if (!Utils.CanInstantiate(targetType)) { return(false); } Type valueType; if (!IsSupportedDictionaryType(targetType, out valueType)) { return(false); } var dictionary = Utils.Instantiate(targetType); var idictionary = dictionary as IDictionary; var propertyStorage = new SimplePropertyStorage(valueType); foreach (var kvp in map) { var key = kvp.Key; var entry = kvp.Value; var item = FromDynamoDBEntry(propertyStorage, entry, flatConfig); idictionary.Add(key, item); } output = dictionary; return(true); }