using System.Data;

namespace e_suite.Database.Audit.Extensions;

public static class DictionaryExtensions
{
    public static void AddRange<TKey, TValue>(this Dictionary<TKey, TValue> source, Dictionary<TKey, TValue> collection) where TKey : notnull
    {
        ArgumentNullException.ThrowIfNull(collection, nameof(collection));

        foreach (var item in collection)
        {
            if (!source.ContainsKey(item.Key))
            {
                source.Add(item.Key, item.Value);
            }
            else
            {
                throw new DuplicateNameException("duplicate entries found whilst combining dictionaries");
            }
        }
    }
}