From d437950ac30ee294ab275362abe711ae3c14ac32 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Wed, 11 Mar 2020 22:55:10 +0100 Subject: [PATCH] Parse config value correctly --- .../Extensions/ConfigurationExtensions.cs | 17 +---------------- .../MediaBrowser.Controller.csproj | 1 + 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs index 9dbc1a243f..1a9ac09ee9 100644 --- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs +++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.Controller.Extensions /// The parsed config value. /// The config value is not a valid bool string. See . public static bool IsNoWebContent(this IConfiguration configuration) - => configuration.ParseBoolean(NoWebContentKey); + => configuration.GetValue(NoWebContentKey); /// /// Retrieves the FFmpeg probe size from the . @@ -48,20 +48,5 @@ namespace MediaBrowser.Controller.Extensions /// The FFmpeg analyse duration option. public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration) => configuration[FfmpegAnalyzeDurationKey]; - - /// - /// Convert the specified configuration string value its equivalent. - /// - /// The configuration to retrieve and parse the setting from. - /// The key to use to retrieve the string value from the configuration. - /// The parsed boolean value. - /// The config value is not a valid bool string. See . - public static bool ParseBoolean(this IConfiguration configuration, string key) - { - string configValue = configuration[key]; - return bool.TryParse(configValue, out bool result) ? - result : - throw new FormatException($"Invalid value for configuration option '{key}' (expected a boolean): {configValue}"); - } } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 88e9055e84..bcca9e4a18 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -9,6 +9,7 @@ +