Ejemplo n.º 1
0
        internal ReflectionJsonTypeInfo(JsonConverter converter, JsonSerializerOptions options)
            : base(converter, options)
        {
            NumberHandling      = GetNumberHandlingForType(Type);
            PolymorphismOptions = JsonPolymorphismOptions.CreateFromAttributeDeclarations(Type);
            MapInterfaceTypesToCallbacks();

            if (PropertyInfoForTypeInfo.ConverterStrategy == ConverterStrategy.Object)
            {
                AddPropertiesAndParametersUsingReflection();
            }

            Func <object>?createObject = Options.MemberAccessorStrategy.CreateConstructor(typeof(T));

            if (converter.UsesDefaultConstructor)
            {
                SetCreateObject(createObject);
            }

            CreateObjectForExtensionDataProperty = createObject;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates serialization metadata for a type using a simple converter.
 /// </summary>
 public SourceGenJsonTypeInfo(JsonConverter converter, JsonSerializerOptions options)
     : base(converter, options)
 {
     PolymorphismOptions = JsonPolymorphismOptions.CreateFromAttributeDeclarations(Type);
     MapInterfaceTypesToCallbacks();
 }