namespace Piwigo.Client; internal static class DictionaryExtensions { public static IDictionary AddIfValueNotNull(this IDictionary dictionary, string key, string? value) { if (dictionary == null) { throw new ArgumentNullException(nameof(dictionary)); } if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(key)); } if (value is not null) { dictionary.Add(key, value); } return dictionary; } }