コード例 #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;
        }
コード例 #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();
 }