Use C# 4.0 dynamic to drastically simplify your private reflection code

Update 8/10/2011: this project now has a home at https://github.com/davidebbo/ReflectionMagic. Also, it is installable via nuget. It’s named ‘ReflectionMagic’.   Private reflection allows you to access private and internal members in other assemblies.  Generally, it’s considered to be a bad thing to do, as it ties you to undocumented implementation details which can later break you. …

15

Passing anonymous objects to MVC views and accessing them using dynamic

Note (12/22/2011): now that MVC 3 has direct support for dynamic, the technique below is no longer necessary. This post is in fact what led to integrating the feature into MVC! First, I’ll start with a little disclaimer: this post is not about whether using dynamic is better/worse than static typing.  Instead, it’s about making…

26

Using C# Dynamic to simplify ADO.NET Data Access

Update (11/7/09): fixed Execute() method per Richard’s suggestion to wrap IDataRecord instead of Reader. Recently, I started playing around with C# dynamic, and blogged how it could be used to call static class members late bound.  Today, I was talking to Phil Haack, who I think had talked to ScottGu, and he mentioned that it…

16

Using C# dynamic to call static members

By now, you’ve probably heard that C# 4.0 is adding support for the dynamic keyword, which introduces some aspects of dynamic languages to C#.  I had not had a chance to really try it, but recently I was reading Bertrand Le Roy’s post on the topic, and was sort of looking for a good opportunity…

17