// <auto-generated/>

#nullable enable annotations
#nullable disable warnings

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

namespace System.Runtime.CompilerServices
{
    using System;
    using System.CodeDom.Compiler;

    [GeneratedCode("Microsoft.Extensions.Configuration.Binder.SourceGeneration", "42.42.42.42")]
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
    file sealed class InterceptsLocationAttribute : Attribute
    {
        public InterceptsLocationAttribute(int version, string data)
        {
        }
    }
}

namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
{
    using Microsoft.Extensions.Configuration;
    using System;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Runtime.CompilerServices;

    [GeneratedCode("Microsoft.Extensions.Configuration.Binder.SourceGeneration", "42.42.42.42")]
    file static class BindingExtensions
    {
        #region IConfiguration extensions.
        /// <summary>Attempts to bind the given object instance to configuration values by matching property names against configuration keys recursively.</summary>
        [InterceptsLocation(1, "afrwH3rJzSfhL67foIuQbjoBAABzcmMtMC5jcw==")] // src-0.cs(13,16)
        public static void Bind_ProgramMyClass(this IConfiguration configuration, object? instance)
        {
            if (configuration is null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (instance is null)
            {
                return;
            }

            var typedObj = (global::Program.MyClass)instance;
            BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null);
        }
        #endregion IConfiguration extensions.

        #region Core binding extensions.
        private readonly static Lazy<HashSet<string>> s_configKeys_ProgramMyClass = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Prop0", "Prop1", "Prop2", "Prop3", "Prop4", "Prop5", "Prop6", "Prop8", "Prop9", "Prop10", "Prop13", "Prop14", "Prop15", "Prop16", "Prop17", "Prop19", "Prop20", "Prop21", "Prop23", "Prop24", "Prop25", "Prop26", "Prop27", "Prop28", "Prop29", "Prop30" });

        public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions)
        {
            ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions);

            if (configuration["Prop0"] is string value0 && !string.IsNullOrEmpty(value0))
            {
                instance.Prop0 = ParseBool(value0, configuration.GetSection("Prop0").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop0 = instance.Prop0;
            }

            if (configuration["Prop1"] is string value1 && !string.IsNullOrEmpty(value1))
            {
                instance.Prop1 = ParseByte(value1, configuration.GetSection("Prop1").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop1 = instance.Prop1;
            }

            if (configuration["Prop2"] is string value2 && !string.IsNullOrEmpty(value2))
            {
                instance.Prop2 = ParseSbyte(value2, configuration.GetSection("Prop2").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop2 = instance.Prop2;
            }

            if (configuration["Prop3"] is string value3 && !string.IsNullOrEmpty(value3))
            {
                instance.Prop3 = ParseChar(value3, configuration.GetSection("Prop3").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop3 = instance.Prop3;
            }

            if (configuration["Prop4"] is string value4 && !string.IsNullOrEmpty(value4))
            {
                instance.Prop4 = ParseDouble(value4, configuration.GetSection("Prop4").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop4 = instance.Prop4;
            }

            if (configuration["Prop5"] is string value5)
            {
                instance.Prop5 = value5;
            }
            else if (defaultValueIfNotFound)
            {
                var currentValue = instance.Prop5;
                if (currentValue is not null)
                {
                    instance.Prop5 = currentValue;
                }
            }

            if (configuration["Prop6"] is string value6 && !string.IsNullOrEmpty(value6))
            {
                instance.Prop6 = ParseInt(value6, configuration.GetSection("Prop6").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop6 = instance.Prop6;
            }

            if (configuration["Prop8"] is string value7 && !string.IsNullOrEmpty(value7))
            {
                instance.Prop8 = ParseShort(value7, configuration.GetSection("Prop8").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop8 = instance.Prop8;
            }

            if (configuration["Prop9"] is string value8 && !string.IsNullOrEmpty(value8))
            {
                instance.Prop9 = ParseLong(value8, configuration.GetSection("Prop9").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop9 = instance.Prop9;
            }

            if (configuration["Prop10"] is string value9 && !string.IsNullOrEmpty(value9))
            {
                instance.Prop10 = ParseFloat(value9, configuration.GetSection("Prop10").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop10 = instance.Prop10;
            }

            if (configuration["Prop13"] is string value10 && !string.IsNullOrEmpty(value10))
            {
                instance.Prop13 = ParseUshort(value10, configuration.GetSection("Prop13").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop13 = instance.Prop13;
            }

            if (configuration["Prop14"] is string value11 && !string.IsNullOrEmpty(value11))
            {
                instance.Prop14 = ParseUint(value11, configuration.GetSection("Prop14").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop14 = instance.Prop14;
            }

            if (configuration["Prop15"] is string value12 && !string.IsNullOrEmpty(value12))
            {
                instance.Prop15 = ParseUlong(value12, configuration.GetSection("Prop15").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop15 = instance.Prop15;
            }

            if (configuration["Prop16"] is string value13)
            {
                instance.Prop16 = value13;
            }
            else if (defaultValueIfNotFound)
            {
                var currentValue = instance.Prop16;
                if (currentValue is not null)
                {
                    instance.Prop16 = currentValue;
                }
            }

            if (configuration["Prop17"] is string value14 && !string.IsNullOrEmpty(value14))
            {
                instance.Prop17 = ParseSystemGlobalizationCultureInfo(value14, configuration.GetSection("Prop17").Path);
            }
            else if (defaultValueIfNotFound)
            {
                var currentValue = instance.Prop17;
                if (currentValue is not null)
                {
                    instance.Prop17 = currentValue;
                }
            }

            if (configuration["Prop19"] is string value15 && !string.IsNullOrEmpty(value15))
            {
                instance.Prop19 = ParseSystemDateTime(value15, configuration.GetSection("Prop19").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop19 = instance.Prop19;
            }

            if (configuration["Prop20"] is string value16 && !string.IsNullOrEmpty(value16))
            {
                instance.Prop20 = ParseSystemDateTimeOffset(value16, configuration.GetSection("Prop20").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop20 = instance.Prop20;
            }

            if (configuration["Prop21"] is string value17 && !string.IsNullOrEmpty(value17))
            {
                instance.Prop21 = ParseDecimal(value17, configuration.GetSection("Prop21").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop21 = instance.Prop21;
            }

            if (configuration["Prop23"] is string value18 && !string.IsNullOrEmpty(value18))
            {
                instance.Prop23 = ParseSystemTimeSpan(value18, configuration.GetSection("Prop23").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop23 = instance.Prop23;
            }

            if (configuration["Prop24"] is string value19 && !string.IsNullOrEmpty(value19))
            {
                instance.Prop24 = ParseSystemGuid(value19, configuration.GetSection("Prop24").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop24 = instance.Prop24;
            }

            if (configuration["Prop25"] is string value20 && !string.IsNullOrEmpty(value20))
            {
                instance.Prop25 = ParseSystemUri(value20, configuration.GetSection("Prop25").Path);
            }
            else if (defaultValueIfNotFound)
            {
                var currentValue = instance.Prop25;
                if (currentValue is not null)
                {
                    instance.Prop25 = currentValue;
                }
            }

            if (configuration["Prop26"] is string value21 && !string.IsNullOrEmpty(value21))
            {
                instance.Prop26 = ParseSystemVersion(value21, configuration.GetSection("Prop26").Path);
            }
            else if (defaultValueIfNotFound)
            {
                var currentValue = instance.Prop26;
                if (currentValue is not null)
                {
                    instance.Prop26 = currentValue;
                }
            }

            if (configuration["Prop27"] is string value22 && !string.IsNullOrEmpty(value22))
            {
                instance.Prop27 = ParseEnum<global::System.DayOfWeek>(value22, configuration.GetSection("Prop27").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop27 = instance.Prop27;
            }

            if (configuration["Prop28"] is string value23 && !string.IsNullOrEmpty(value23))
            {
                instance.Prop28 = ParseByteArray(value23, configuration.GetSection("Prop28").Path);
            }
            else if (defaultValueIfNotFound)
            {
                var currentValue = instance.Prop28;
                if (currentValue is not null)
                {
                    instance.Prop28 = currentValue;
                }
            }

            if (configuration["Prop29"] is string value24 && !string.IsNullOrEmpty(value24))
            {
                instance.Prop29 = ParseInt(value24, configuration.GetSection("Prop29").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop29 = instance.Prop29;
            }

            if (configuration["Prop30"] is string value25 && !string.IsNullOrEmpty(value25))
            {
                instance.Prop30 = ParseSystemDateTime(value25, configuration.GetSection("Prop30").Path);
            }
            else if (defaultValueIfNotFound)
            {
                instance.Prop30 = instance.Prop30;
            }
        }


        /// <summary>If required by the binder options, validates that there are no unknown keys in the input configuration object.</summary>
        public static void ValidateConfigurationKeys(Type type, Lazy<HashSet<string>> keys, IConfiguration configuration, BinderOptions? binderOptions)
        {
            if (binderOptions?.ErrorOnUnknownConfiguration is true)
            {
                List<string>? temp = null;
        
                foreach (IConfigurationSection section in configuration.GetChildren())
                {
                    if (!keys.Value.Contains(section.Key))
                    {
                        (temp ??= new List<string>()).Add($"'{section.Key}'");
                    }
                }
        
                if (temp is not null)
                {
                    throw new InvalidOperationException($"'ErrorOnUnknownConfiguration' was set on the provided BinderOptions, but the following properties were not found on the instance of {type}: {string.Join(", ", temp)}");
                }
            }
        }

        public static T ParseEnum<T>(string value, string? path) where T : struct
        {
            try
            {
                return (T)Enum.Parse(typeof(T), value, ignoreCase: true);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(T)}'.", exception);
            }
        }

        public static bool ParseBool(string value, string? path)
        {
            try
            {
                return bool.Parse(value);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(bool)}'.", exception);
            }
        }

        public static byte ParseByte(string value, string? path)
        {
            try
            {
                return byte.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(byte)}'.", exception);
            }
        }

        public static sbyte ParseSbyte(string value, string? path)
        {
            try
            {
                return sbyte.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(sbyte)}'.", exception);
            }
        }

        public static char ParseChar(string value, string? path)
        {
            try
            {
                return char.Parse(value);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(char)}'.", exception);
            }
        }

        public static double ParseDouble(string value, string? path)
        {
            try
            {
                return double.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(double)}'.", exception);
            }
        }

        public static int ParseInt(string value, string? path)
        {
            try
            {
                return int.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(int)}'.", exception);
            }
        }

        public static short ParseShort(string value, string? path)
        {
            try
            {
                return short.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(short)}'.", exception);
            }
        }

        public static long ParseLong(string value, string? path)
        {
            try
            {
                return long.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(long)}'.", exception);
            }
        }

        public static float ParseFloat(string value, string? path)
        {
            try
            {
                return float.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(float)}'.", exception);
            }
        }

        public static ushort ParseUshort(string value, string? path)
        {
            try
            {
                return ushort.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(ushort)}'.", exception);
            }
        }

        public static uint ParseUint(string value, string? path)
        {
            try
            {
                return uint.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(uint)}'.", exception);
            }
        }

        public static ulong ParseUlong(string value, string? path)
        {
            try
            {
                return ulong.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(ulong)}'.", exception);
            }
        }

        public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, string? path)
        {
            try
            {
                return CultureInfo.GetCultureInfo(value);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception);
            }
        }

        public static global::System.DateTime ParseSystemDateTime(string value, string? path)
        {
            try
            {
                return global::System.DateTime.Parse(value, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.DateTime)}'.", exception);
            }
        }

        public static global::System.DateTimeOffset ParseSystemDateTimeOffset(string value, string? path)
        {
            try
            {
                return global::System.DateTimeOffset.Parse(value, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.DateTimeOffset)}'.", exception);
            }
        }

        public static decimal ParseDecimal(string value, string? path)
        {
            try
            {
                return decimal.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(decimal)}'.", exception);
            }
        }

        public static global::System.TimeSpan ParseSystemTimeSpan(string value, string? path)
        {
            try
            {
                return global::System.TimeSpan.Parse(value, CultureInfo.InvariantCulture);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.TimeSpan)}'.", exception);
            }
        }

        public static global::System.Guid ParseSystemGuid(string value, string? path)
        {
            try
            {
                return global::System.Guid.Parse(value);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.Guid)}'.", exception);
            }
        }

        public static global::System.Uri ParseSystemUri(string value, string? path)
        {
            try
            {
                return new Uri(value, UriKind.RelativeOrAbsolute);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.Uri)}'.", exception);
            }
        }

        public static global::System.Version ParseSystemVersion(string value, string? path)
        {
            try
            {
                return global::System.Version.Parse(value);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(global::System.Version)}'.", exception);
            }
        }

        public static byte[] ParseByteArray(string value, string? path)
        {
            try
            {
                return Convert.FromBase64String(value);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"Failed to convert configuration value at '{path}' to type '{typeof(byte[])}'.", exception);
            }
        }
        #endregion Core binding extensions.
    }
}
