Skip to content

Commit

Permalink
Merge pull request #73 from glennblock/dev
Browse files Browse the repository at this point in the history
Fixing bug causing dups
  • Loading branch information
glennblock committed Jul 7, 2014
2 parents d3aa98f + 6a5ab51 commit 8a69674
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/WebApiContrib.CollectionJson/ExtensibleObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ public abstract class ExtensibleObject : DynamicObject
{
public ExtensibleObject()
{
Members = new Dictionary<string, object>(StringComparer.CurrentCultureIgnoreCase);
Members = new Dictionary<string, object>();
DynamicMembers = new Dictionary<string, object>(StringComparer.CurrentCultureIgnoreCase);
}

protected IDictionary<string, object> Members { get; private set; }
protected IDictionary<string, object> Members { get; private set; }
protected IDictionary<string, object> 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;
Expand All @@ -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<string> GetDynamicMemberNames()
{
foreach (var entry in Members)
foreach (var entry in DynamicMembers)
{
if (entry.Value != null)
yield return entry.Key;
Expand Down

0 comments on commit 8a69674

Please sign in to comment.