namespace AssetRipper.SourceGenerated.Extensions; public static class IDictionaryExtensions { public static void AddRange(this IDictionary _this, IReadOnlyDictionary source) { foreach (KeyValuePair argument in source) { _this.Add(argument.Key, argument.Value); } } public static T2 GetOrAdd(this IDictionary _this, T1 key) where T1 : notnull where T2 : new() { if (!_this.TryGetValue(key, out T2? value)) { value = new(); _this.Add(key, value); } return value; } public static T2 GetOrAdd(this IDictionary _this, T1 key, Func factory) where T1 : notnull { if (!_this.TryGetValue(key, out T2? value)) { value = factory(); _this.Add(key, value); } return value; } public static TValue? TryGetValue(this IReadOnlyDictionary _this, TKey key) where TKey : notnull { _this.TryGetValue(key, out TValue? value); return value; } /// /// .NET Core 3.0+ only. /// public static void RemoveAll(this Dictionary source, Predicate> predicate) where TKey : notnull { foreach (KeyValuePair pair in source) { if (predicate(pair)) { source.Remove(pair.Key); } } } }