// <auto-generated/>

#nullable enable annotations
#nullable disable warnings

// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0612, CS0618

namespace TestApp
{
    internal partial class MyContext
    {
        private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Measurement>? _Measurement;
        
        /// <summary>
        /// Defines the source generated JSON serialization contract metadata for a given type.
        /// </summary>
        #nullable disable annotations // Marking the property type as nullable-oblivious.
        public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Measurement> Measurement
        #nullable enable annotations
        {
            get => _Measurement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Measurement>)Options.GetTypeInfo(typeof(global::TestApp.Measurement));
        }
        
        private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Measurement> Create_Measurement(global::System.Text.Json.JsonSerializerOptions options)
        {
            if (!TryGetTypeInfoForRuntimeCustomConverter<global::TestApp.Measurement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Measurement> jsonTypeInfo))
            {
                var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::TestApp.Measurement>
                {
                    ObjectCreator = () => new global::TestApp.Measurement(),
                    ObjectWithParameterizedConstructorCreator = null,
                    PropertyMetadataInitializer = _ => MeasurementPropInit(options),
                    ConstructorParameterMetadataInitializer = null,
                    ConstructorAttributeProviderFactory = static () => typeof(global::TestApp.Measurement).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
                    SerializeHandler = MeasurementSerializeHandler,
                    PolymorphismOptions = new global::System.Text.Json.Serialization.Metadata.JsonPolymorphismOptions(),
                    TypeClassifierFactory = null,
                };
                
                jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::TestApp.Measurement>(options, objectInfo);
                jsonTypeInfo.NumberHandling = null;
            }
        
            jsonTypeInfo.OriginatingResolver = this;
            return jsonTypeInfo;
        }

        private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] MeasurementPropInit(global::System.Text.Json.JsonSerializerOptions options)
        {
            var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[3];

            var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<double>
            {
                IsProperty = true,
                IsPublic = true,
                IsVirtual = false,
                DeclaringType = typeof(global::TestApp.Measurement),
                Converter = null,
                Getter = static obj => ((global::TestApp.Measurement)obj).Value,
                Setter = static (obj, value) => ((global::TestApp.Measurement)obj).Value = value!,
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Value",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.Measurement).GetProperty("Value", InstanceMemberBindingFlags, null, typeof(double), global::System.Array.Empty<global::System.Type>(), null),
            };
            
            properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<double>(options, info0);

            var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<double?>
            {
                IsProperty = true,
                IsPublic = true,
                IsVirtual = false,
                DeclaringType = typeof(global::TestApp.Measurement),
                Converter = null,
                Getter = static obj => ((global::TestApp.Measurement)obj).Margin,
                Setter = static (obj, value) => ((global::TestApp.Measurement)obj).Margin = value!,
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Margin",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.Measurement).GetProperty("Margin", InstanceMemberBindingFlags, null, typeof(double?), global::System.Array.Empty<global::System.Type>(), null),
            };
            
            properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<double?>(options, info1);

            var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<int?>
            {
                IsProperty = true,
                IsPublic = true,
                IsVirtual = false,
                DeclaringType = typeof(global::TestApp.Measurement),
                Converter = null,
                Getter = static obj => ((global::TestApp.Measurement)obj).Count,
                Setter = static (obj, value) => ((global::TestApp.Measurement)obj).Count = value!,
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Count",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.Measurement).GetProperty("Count", InstanceMemberBindingFlags, null, typeof(int?), global::System.Array.Empty<global::System.Type>(), null),
            };
            
            properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<int?>(options, info2);

            return properties;
        }

        // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance
        // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk.
        private void MeasurementSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::TestApp.Measurement? value)
        {
            if (value is null)
            {
                writer.WriteNullValue();
                return;
            }
            
            writer.WriteStartObject();

            writer.WriteNumber(PropName_Value, ((global::TestApp.Measurement)value).Value);
            writer.WritePropertyName(PropName_Margin);
            global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::TestApp.Measurement)value).Margin, NullableDouble);
            writer.WritePropertyName(PropName_Count);
            global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::TestApp.Measurement)value).Count, NullableInt32);

            writer.WriteEndObject();
        }
    }
}
