I have the following object:
dynamic person = new {Id = 1, Name = "SpiderMan"};
I need to be able to iterate through the property names e.g. "Id"
, "Name"
.
I also need to be able to achieve this in the most efficient way therefore I chose to use FastMember however it's api does not allow me to iterate through the properties.
Any ideas?
[UPDATE]
Thanks to Marc I managed to achieve what I wanted using:
dynamic person = new { Id = 1, Name = "SpiderMan" };
MemberSet members = TypeAccessor.Create(person.GetType()).GetMembers();
foreach (Member item in members)
{
// do whatever
}
GetMembers()
works great for my scenario. Any plans for migrating the source code from GoogleCode over to GitHub? Once again tnx for this brilliant library. – Marvelous