c# - How do I reflect over the members of dynamic object? -
i need dictionary of properties , values object declared dynamic keyword in .net 4? seems using reflection not work.
example:
dynamic s = new expandoobject(); s.path = "/home"; s.name = "home"; // how enumerate path , name properties , values? idictionary<string, object> propertyvalues = ???
if idynamicmetaobjectprovider can provide dynamic member names, can them. see getmembernames implementation in apache licensed pcl library dynamitey (which can found in nuget), works expandoobject
s , dynamicobject
s implement getdynamicmembernames
, other idynamicmetaobjectprovider
provides meta object implementation of getdynamicmembernames
without custom testing beyond is idynamicmetaobjectprovider
.
after getting member names it's little more work value right way, impromptu it's harder point interesting bits , have make sense. here's documentation , equal or faster reflection, however, unlikely faster dictionary lookup expando, works object, expando, dynamic or original - name it.
Comments
Post a Comment