| File: _generated\0\BindingExtensions.g.cs | Web Access |
| Project: src\runtime\src\libraries\Microsoft.Extensions.Logging.EventLog\src\Microsoft.Extensions.Logging.EventLog.csproj (Microsoft.Extensions.Logging.EventLog) |
// <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", "11.0.14.37201")] [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", "11.0.14.37201")] 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, "WYB72++FVmOQqtXk3gpuopEEAABFdmVudExvZ0NvbmZpZ3VyZU9wdGlvbnMuY3M=")] // /_/src/runtime/src/libraries/Microsoft.Extensions.Logging.EventLog/src/EventLogConfigureOptions.cs(29,75) public static void Bind_Microsoft__Extensions__Logging__EventLog__EventLogSettings(this IConfiguration configuration, object? instance) { ArgumentNullException.ThrowIfNull(configuration); if (instance is null) { return; } var typedObj = (global::Microsoft.Extensions.Logging.EventLog.EventLogSettings)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. #region Core binding extensions. private readonly static Lazy<global::System.Collections.Generic.HashSet<string>> s_configKeys_Microsoft__Extensions__Logging__EventLog__IEventLog = new(() => new global::System.Collections.Generic.HashSet<string>(StringComparer.OrdinalIgnoreCase) { "DefaultEventId", "MaxMessageSize" }); private readonly static Lazy<global::System.Collections.Generic.HashSet<string>> s_configKeys_Microsoft__Extensions__Logging__EventLog__EventLogSettings = new(() => new global::System.Collections.Generic.HashSet<string>(StringComparer.OrdinalIgnoreCase) { "LogName", "SourceName", "MachineName", "EventLog" }); public static void BindCore(IConfiguration configuration, ref global::Microsoft.Extensions.Logging.EventLog.IEventLog instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(global::Microsoft.Extensions.Logging.EventLog.IEventLog), s_configKeys_Microsoft__Extensions__Logging__EventLog__IEventLog, configuration, binderOptions); } public static void BindCore(IConfiguration configuration, ref global::Microsoft.Extensions.Logging.EventLog.EventLogSettings instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(global::Microsoft.Extensions.Logging.EventLog.EventLogSettings), s_configKeys_Microsoft__Extensions__Logging__EventLog__EventLogSettings, configuration, binderOptions); if (TryGetConfigurationValue(configuration, key: "LogName", out string? value0)) { instance.LogName = value0; } else if (defaultValueIfNotFound) { var currentValue = instance.LogName; if (currentValue is not null) { instance.LogName = currentValue; } } if (TryGetConfigurationValue(configuration, key: "SourceName", out string? value1)) { instance.SourceName = value1; } else if (defaultValueIfNotFound) { var currentValue = instance.SourceName; if (currentValue is not null) { instance.SourceName = currentValue; } } if (TryGetConfigurationValue(configuration, key: "MachineName", out string? value2)) { instance.MachineName = value2; } else if (defaultValueIfNotFound) { var currentValue = instance.MachineName; if (currentValue is not null) { instance.MachineName = currentValue; } } } /// <summary>Tries to get the configuration value for the specified key.</summary> public static bool TryGetConfigurationValue(IConfiguration configuration, string key, out string? value) { if (configuration is ConfigurationSection section) { return section.TryGetValue(key, out value); } value = key != null ? configuration[key] : configuration is IConfigurationSection sec ? sec.Value : null; return value != null; } /// <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<global::System.Collections.Generic.HashSet<string>> keys, IConfiguration configuration, BinderOptions? binderOptions) { if (binderOptions?.ErrorOnUnknownConfiguration is true) { global::System.Collections.Generic.List<string>? temp = null; foreach (IConfigurationSection section in configuration.GetChildren()) { if (!keys.Value.Contains(section.Key)) { (temp ??= new global::System.Collections.Generic.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 IConfiguration? AsConfigWithChildren(IConfiguration configuration) { foreach (IConfigurationSection _ in configuration.GetChildren()) { return configuration; } return null; } 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 '{value ?? "null"}' at '{path}' to type '{typeof(int)}'.", exception); } } #endregion Core binding extensions. } }