From ce7a7c7cf3bc585481e9290d18ea156502485950 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Thu, 14 Nov 2013 11:32:25 +0100 Subject: [PATCH] New Add() methods analogous to FunctionCollection --- Source/Bind/Structures/Enum.cs | 36 +++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Source/Bind/Structures/Enum.cs b/Source/Bind/Structures/Enum.cs index 89047f6e..0c105ec8 100644 --- a/Source/Bind/Structures/Enum.cs +++ b/Source/Bind/Structures/Enum.cs @@ -79,12 +79,6 @@ namespace Bind.Structures { SortedDictionary Enumerations = new SortedDictionary(); - internal void AddRange(EnumCollection enums) - { - foreach (Enum e in enums.Values) - Utilities.Merge(this, e); - } - // Return -1 for ext1, 1 for ext2 or 0 if no preference. int OrderOfPreference(string ext1, string ext2) { @@ -115,11 +109,39 @@ namespace Bind.Structures return 0; } + #region Public Members + + public void Add(Enum e) + { + Add(e.Name, e); + } + + public void AddRange(EnumCollection enums) + { + foreach (Enum e in enums.Values) + { + Add(e); + } + } + + #endregion + #region IDictionary Members public void Add(string key, Enum value) { - Enumerations.Add(key, value); + if (ContainsKey(key)) + { + var e = this[key]; + foreach (var token in value.ConstantCollection.Values) + { + Utilities.Merge(e, token); + } + } + else + { + Enumerations.Add(key, value); + } } public bool ContainsKey(string key)