private static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args). ConfigureAppConfiguration((hostingContext, configuration) => { var configRoot = configuration.Build(); var config = BatteryMaxConfiguration.StaticDefaults(); configRoot.Bind(config); Settings.Initialize(config); });
public static void Initialize(BatteryMaxConfiguration config) { MinimumCharge = GetChargeLevel(config.ChargeLevels.Minimum, nameof(MinimumCharge)); MaximumCharge = GetChargeLevel(config.ChargeLevels.Maximum, nameof(MaximumCharge)); ValidateChargeLevels(); BackgroundColor = GetIconColor(config.IconColors.Background, nameof(BackgroundColor)); ForegroundColorDarkTheme = GetIconColor(config.IconColors.ForegroundDarkTheme, nameof(ForegroundColorDarkTheme)); ForegroundColorLightTheme = GetIconColor(config.IconColors.ForegroundLightTheme, nameof(ForegroundColorLightTheme)); ChargingColor = GetIconColor(config.IconColors.Charging, nameof(ChargingColor)); DrainingColor = GetIconColor(config.IconColors.Draining, nameof(DrainingColor)); WarningColor = GetIconColor(config.IconColors.Warning, nameof(WarningColor)); CriticalColor = GetIconColor(config.IconColors.Critical, nameof(CriticalColor)); var batteryIconDefaults = BatteryMaxConfiguration.BatteryIconDefaults(); BatteryIcon100 = config.BatteryIcon100 ?? batteryIconDefaults.BatteryIcon100; BatteryIcon150 = config.BatteryIcon150 ?? batteryIconDefaults.BatteryIcon150; }