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

namespace CLOU_Comm.Helper
{
public static class DicExHelper
{
public static bool ContainsKeys<TKey, TValue>(this Dictionary<TKey, TValue> dic, List<TKey> keys)
{
foreach (var item in keys)
{
if (!dic.ContainsKey(item))
{
return false;
}
}

return true;
}

public static Dictionary<TKey, TValue> TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> dic, TKey key, TValue value)
{
if (!dic.ContainsKey(key))
dic.Add(key, value);
return dic;
}

public static Dictionary<TKey, TValue> UpdateDic<TKey, TValue>(this Dictionary<TKey, TValue> dest, Dictionary<TKey, TValue> src)
{
if (src == null || src.Count() <= 0) return dest;

foreach (TKey key in src.Keys)
{
if (dest.ContainsKey(key))
{
dest[key] = src[key];
}
else
{
dest.Add(key, src[key]);
}

}
return dest;
}
}
}