BuildsAppReborn.Contracts.Extensions.BuildProviderSettingsExtensions.ThrowIfKeyNotExistsAndValueEmpty C# (CSharp) Method

ThrowIfKeyNotExistsAndValueEmpty() public static method

public static ThrowIfKeyNotExistsAndValueEmpty ( BuildMonitorSettings settings, String key ) : void
settings BuildMonitorSettings
key String
return void
        public static void ThrowIfKeyNotExistsAndValueEmpty(this BuildMonitorSettings settings, String key)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (String.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            settings.ThrowIfKeyNotExists(key);

            var value = settings[key];

            if (value == null || value is String && String.IsNullOrEmpty(value.ToString()))
            {
                throw new NullReferenceException($"Value for key {key} must not be empty or null!");
            }
        }
    }