public static void AddItemIfNotEmpty(this IDictionary<string, string> dictionary, string key, string value) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (!string.IsNullOrEmpty(value)) { dictionary[key] = value; } }