public virtual void Initialize( Type parentClassType, Type declaredPropertyType, Type runtimePropertyType, Type implementedPropertyType, PropertyInfo propertyInfo, Type elementType, JsonConverter converter, JsonSerializerOptions options) { ParentClassType = parentClassType; DeclaredPropertyType = declaredPropertyType; RuntimePropertyType = runtimePropertyType; ImplementedPropertyType = implementedPropertyType; PropertyInfo = propertyInfo; ElementType = elementType; Options = options; IsNullableType = runtimePropertyType.IsGenericType && runtimePropertyType.GetGenericTypeDefinition() == typeof(Nullable <>); CanBeNull = IsNullableType || !runtimePropertyType.IsValueType; if (converter != null) { ConverterBase = converter; HasInternalConverter = (converter.GetType().Assembly == GetType().Assembly); // Avoid calling GetClassType since it will re-ask if there is a converter which is slow. if (runtimePropertyType == typeof(object)) { ClassType = ClassType.Unknown; } else { ClassType = ClassType.Value; } } // Special case for immutable collections. else if (declaredPropertyType != implementedPropertyType && !JsonClassInfo.IsNativelySupportedCollection(declaredPropertyType)) { ClassType = JsonClassInfo.GetClassType(declaredPropertyType, options); } else { ClassType = JsonClassInfo.GetClassType(runtimePropertyType, options); } }
public virtual void Initialize( Type parentClassType, Type declaredPropertyType, Type runtimePropertyType, PropertyInfo propertyInfo, Type elementType, JsonSerializerOptions options) { ParentClassType = parentClassType; DeclaredPropertyType = declaredPropertyType; RuntimePropertyType = runtimePropertyType; PropertyInfo = propertyInfo; ClassType = JsonClassInfo.GetClassType(runtimePropertyType); _elementType = elementType; Options = options; IsNullableType = runtimePropertyType.IsGenericType && runtimePropertyType.GetGenericTypeDefinition() == typeof(Nullable <>); CanBeNull = IsNullableType || !runtimePropertyType.IsValueType; }
public virtual void Initialize( Type parentClassType, Type declaredPropertyType, Type runtimePropertyType, PropertyInfo propertyInfo, Type elementType, JsonConverter converter, JsonSerializerOptions options) { ParentClassType = parentClassType; DeclaredPropertyType = declaredPropertyType; RuntimePropertyType = runtimePropertyType; PropertyInfo = propertyInfo; _elementType = elementType; Options = options; IsNullableType = runtimePropertyType.IsGenericType && runtimePropertyType.GetGenericTypeDefinition() == typeof(Nullable <>); CanBeNull = IsNullableType || !runtimePropertyType.IsValueType; if (converter != null) { ConverterBase = converter; // Avoid calling GetClassType since it will re-ask if there is a converter which is slow. if (runtimePropertyType == typeof(object)) { ClassType = ClassType.Unknown; } else { ClassType = ClassType.Value; } } else { ClassType = JsonClassInfo.GetClassType(runtimePropertyType, options); } }