using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; namespace Tensorflow.Common.Extensions { public static class DictionaryExtension { public static void Deconstruct(this KeyValuePair pair, out T1 first, out T2 second) { first = pair.Key; second = pair.Value; } public static void Update(this Dictionary dic, IDictionary other) { foreach(var (key, value) in other) { dic[key] = value; } } public static T2 GetOrDefault(this Dictionary dic, T1 key, T2 defaultValue) { if (dic.ContainsKey(key)) { return dic[key]; } return defaultValue; } } }