Skip to content

Instantly share code, notes, and snippets.

@pawelpabich
Created May 7, 2013 00:07
Show Gist options
  • Save pawelpabich/5529306 to your computer and use it in GitHub Desktop.
Save pawelpabich/5529306 to your computer and use it in GitHub Desktop.
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