// <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.Coordinate>? _Coordinate;
        
        /// <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.Coordinate> Coordinate
        #nullable enable annotations
        {
            get => _Coordinate ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Coordinate>)Options.GetTypeInfo(typeof(global::TestApp.Coordinate));
        }
        
        private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Coordinate> Create_Coordinate(global::System.Text.Json.JsonSerializerOptions options)
        {
            if (!TryGetTypeInfoForRuntimeCustomConverter<global::TestApp.Coordinate>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.Coordinate> jsonTypeInfo))
            {
                var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::TestApp.Coordinate>
                {
                    ObjectCreator = null,
                    ObjectWithParameterizedConstructorCreator = static args => new global::TestApp.Coordinate((double)args[0], (double)args[1]),
                    PropertyMetadataInitializer = _ => CoordinatePropInit(options),
                    ConstructorParameterMetadataInitializer = CoordinateCtorParamInit,
                    ConstructorAttributeProviderFactory = static () => typeof(global::TestApp.Coordinate).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(double), typeof(double)}, modifiers: null),
                    SerializeHandler = CoordinateSerializeHandler,
                    PolymorphismOptions = new global::System.Text.Json.Serialization.Metadata.JsonPolymorphismOptions(),
                    TypeClassifierFactory = null,
                };
                
                jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::TestApp.Coordinate>(options, objectInfo);
                jsonTypeInfo.NumberHandling = null;
            }
        
            jsonTypeInfo.OriginatingResolver = this;
            return jsonTypeInfo;
        }

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

            var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<double>
            {
                IsProperty = true,
                IsPublic = true,
                IsVirtual = false,
                DeclaringType = typeof(global::TestApp.Coordinate),
                Converter = null,
                Getter = static obj => ((global::TestApp.Coordinate)obj).Latitude,
                Setter = static (obj, value) => __set_Coordinate_Latitude((global::TestApp.Coordinate)obj, value!),
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Latitude",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.Coordinate).GetProperty("Latitude", 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.Coordinate),
                Converter = null,
                Getter = static obj => ((global::TestApp.Coordinate)obj).Longitude,
                Setter = static (obj, value) => __set_Coordinate_Longitude((global::TestApp.Coordinate)obj, value!),
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Longitude",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.Coordinate).GetProperty("Longitude", 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);

            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 CoordinateSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::TestApp.Coordinate? value)
        {
            if (value is null)
            {
                writer.WriteNullValue();
                return;
            }
            
            writer.WriteStartObject();

            writer.WriteNumber(PropName_Latitude, ((global::TestApp.Coordinate)value).Latitude);
            writer.WriteNumber(PropName_Longitude, ((global::TestApp.Coordinate)value).Longitude);

            writer.WriteEndObject();
        }

        private static global::System.Text.Json.Serialization.Metadata.JsonParameterInfoValues[] CoordinateCtorParamInit() => new global::System.Text.Json.Serialization.Metadata.JsonParameterInfoValues[]
        {
            new()
            {
                Name = "Latitude",
                ParameterType = typeof(double),
                Position = 0,
                HasDefaultValue = false,
                DefaultValue = null,
                IsNullable = false,
            },

            new()
            {
                Name = "Longitude",
                ParameterType = typeof(double),
                Position = 1,
                HasDefaultValue = false,
                DefaultValue = null,
                IsNullable = false,
            },
        };

        private static global::System.Action<global::TestApp.Coordinate, double>? s_set_Coordinate_Latitude;
        private static void __set_Coordinate_Latitude(global::TestApp.Coordinate obj, double value) => (s_set_Coordinate_Latitude ??= (global::System.Action<global::TestApp.Coordinate, double>)global::System.Delegate.CreateDelegate(typeof(global::System.Action<global::TestApp.Coordinate, double>), typeof(global::TestApp.Coordinate).GetProperty("Latitude", InstanceMemberBindingFlags, null, typeof(double), global::System.Array.Empty<global::System.Type>(), null)!.GetSetMethod(true)!))(obj, value);
        private static global::System.Action<global::TestApp.Coordinate, double>? s_set_Coordinate_Longitude;
        private static void __set_Coordinate_Longitude(global::TestApp.Coordinate obj, double value) => (s_set_Coordinate_Longitude ??= (global::System.Action<global::TestApp.Coordinate, double>)global::System.Delegate.CreateDelegate(typeof(global::System.Action<global::TestApp.Coordinate, double>), typeof(global::TestApp.Coordinate).GetProperty("Longitude", InstanceMemberBindingFlags, null, typeof(double), global::System.Array.Empty<global::System.Type>(), null)!.GetSetMethod(true)!))(obj, value);
    }
}
