How to do reflection with a dynamic style

I’m not advocating *private* reflection (invoking private/internal fields, properties and methods), but we all know that there are those corner cases where you just can’t avoid it. And there’s a whole lot of scenarios when there are legitimate uses of reflection itself that can also leverage this very cool dynamic syntax (i.e. invoking generic methods where you don’t know the type at compile-time, etc.). In these cases, your code goes from pristine-looking C# to crappy unreadable reflection code.

David Ebbo has explained quite a bit already why this might be needed and how it can be used.

This is a pretty handy tool to have for those rare cases, and it’s pretty small, making it ideal for a ...

Read full article

No Comments