Created
May 7, 2013 00:07
-
-
Save pawelpabich/5529306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExtensibleDynamicObject : DynamicObject | |
{ | |
private readonly Dictionary<string, object> data; | |
public ExtensibleDynamicObject() | |
{ | |
data = new Dictionary<string, object>(); | |
} | |
public override bool TrySetMember(SetMemberBinder binder, object value) | |
{ | |
data[binder.Name] = value; | |
return true; | |
} | |
public override bool TryGetMember(GetMemberBinder binder, out object result) | |
{ | |
result = data[binder.Name]; | |
return true; | |
} | |
public override IEnumerable<string> GetDynamicMemberNames() | |
{ | |
return data.Keys; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment