| 123456789101112131415161718192021222324252627282930313233343536 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MECF.Framework.Common.Extens
- {
- public static class DictionaryExtensions
- {
- public static void TryAddValue<TKey, TValue>(this Dictionary<TKey, List<TValue>> dictionary, TKey key, TValue value)
- {
- if (dictionary.ContainsKey(key))
- {
- dictionary[key].Add(value);
- }
- else
- {
- dictionary.Add(key, new List<TValue> { value });
- }
- }
- public static void TryAddValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
- {
- if (dictionary.ContainsKey(key))
- {
- dictionary[key] = value;
- }
- else
- {
- dictionary.Add(key, value);
- }
- }
- }
- }
|