private static IDataTypeInfo GetDataTypeInfo(Type propertyType, IContractResolver contractResolver) { bool IsNullableType(Type type) => type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>); if (PrimitiveTypeMap.TryGetValue(propertyType, out DataType dataType)) { return(DataTypeInfo.Simple(dataType)); } else if (IsNullableType(propertyType)) { return(GetDataTypeInfo(propertyType.GenericTypeArguments[0], contractResolver)); } else if (TryGetEnumerableElementType(propertyType, out Type elementType)) { IDataTypeInfo elementTypeInfo = GetDataTypeInfo(elementType, contractResolver); return(DataTypeInfo.AsCollection(elementTypeInfo)); } else if (contractResolver.ResolveContract(propertyType) is JsonObjectContract jsonContract) { return(DataTypeInfo.Complex(DataType.Complex, propertyType, jsonContract)); } else { return(DataTypeInfo.Unknown); } }