From 6a5ab5119f660b8086b625016a1f4a60bf920be8 Mon Sep 17 00:00:00 2001 From: Glenn Block Date: Sun, 6 Jul 2014 21:11:49 -0700 Subject: [PATCH] Fixing bug causing dups --- src/WebApiContrib.CollectionJson/ExtensibleObject.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/WebApiContrib.CollectionJson/ExtensibleObject.cs b/src/WebApiContrib.CollectionJson/ExtensibleObject.cs index 83eeb8a..0f37124 100644 --- a/src/WebApiContrib.CollectionJson/ExtensibleObject.cs +++ b/src/WebApiContrib.CollectionJson/ExtensibleObject.cs @@ -12,15 +12,17 @@ public abstract class ExtensibleObject : DynamicObject { public ExtensibleObject() { - Members = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + Members = new Dictionary(); + DynamicMembers = new Dictionary(StringComparer.CurrentCultureIgnoreCase); } - protected IDictionary Members { get; private set; } + protected IDictionary Members { get; private set; } + protected IDictionary DynamicMembers { get; private set; } public override bool TryGetMember(GetMemberBinder binder, out object result) { var name = binder.Name; - var found = Members.TryGetValue(name, out result); + var found = DynamicMembers.TryGetValue(name, out result); if (result == null) return false; @@ -30,13 +32,13 @@ public override bool TryGetMember(GetMemberBinder binder, out object result) public override bool TrySetMember(SetMemberBinder binder, object value) { - Members[binder.Name] = value; + DynamicMembers[binder.Name] = value; return true; } public override IEnumerable GetDynamicMemberNames() { - foreach (var entry in Members) + foreach (var entry in DynamicMembers) { if (entry.Value != null) yield return entry.Key;