about summary refs log blame commit diff
path: root/IRCStates/Extensions.cs
blob: 6cce3d4e35d1b01c7c2b272cf53ccccde1c8f5a8 (plain) (tree)
1
2
3
4
5
6
7






                                    






                                                                            







                                                                                                                       
using System.Collections.Generic;
using System.Linq;

namespace IRCStates
{
    public static class Extensions
    {
        /// <summary>
        /// Update the dictionary with <see cref="other"/>'s keys and values
        /// </summary>
        /// <param name="dict"></param>
        /// <param name="other"></param>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        public static void UpdateWith<TKey, TValue>(this Dictionary<TKey, TValue> dict, Dictionary<TKey, TValue> other)
        {
            if (dict == null || other == null || !other.Any()) return;

            foreach (var (key, value) in other) dict[key] = value;
        }
    }
}