From 692da3253f0b596229acd0e93418a644353321b2 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 16 Oct 2018 14:32:27 -0400 Subject: [PATCH] feat: Adding IcdOrderedDictionary constructor for populating with an existing dictionary --- .../Collections/IcdOrderedDictionary.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ICD.Common.Utils/Collections/IcdOrderedDictionary.cs b/ICD.Common.Utils/Collections/IcdOrderedDictionary.cs index 586ccd6..3699b18 100644 --- a/ICD.Common.Utils/Collections/IcdOrderedDictionary.cs +++ b/ICD.Common.Utils/Collections/IcdOrderedDictionary.cs @@ -80,6 +80,20 @@ namespace ICD.Common.Utils.Collections m_Dictionary = new Dictionary(equalityComparer); } + /// + /// Constructor. + /// + /// + public IcdOrderedDictionary(IEnumerable> dictionary) + : this() + { + if (dictionary == null) + throw new ArgumentNullException("dictionary"); + + foreach (KeyValuePair kvp in dictionary) + Add(kvp.Key, kvp.Value); + } + #region Methods public IEnumerator> GetEnumerator()