From 37a21131d90199b16eca34bd2ad2a894fb9a8534 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 11 Jun 2018 11:48:36 -0400 Subject: [PATCH] feat: Extension method for populating a dict with a sequence of kvps --- .../Extensions/DictionaryExtensions.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs index 1869f54..18a3d0d 100644 --- a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs +++ b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs @@ -239,6 +239,26 @@ namespace ICD.Common.Utils.Extensions return change; } + /// + /// Adds the sequence of items to the dictionary. + /// + /// + /// + /// + /// + [PublicAPI] + public static void AddRange(this IDictionary extends, IEnumerable> items) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (items == null) + throw new ArgumentNullException("items"); + + foreach (KeyValuePair item in items) + extends.Add(item); + } + /// /// Adds the sequence of items to the dictionary. ///