Tag Archives: Reflection

F#: Use reflection to call a private or protected method

This isn’t anything ground breaking so if you are expecting it to be, tough luck. The world doesn’t revolve around you. It revolves around me. Making the switch to F# has caused me to redo a lot of older framework stuff and using reflection to call methods is part of that stuff. I could sit [...]

Leave a comment Continue Reading →

Duck Typing my way to a Universal String Convert

So being the beacon of ignorance in the fog of brilliance, I had no idea what Duck Typing was. In short it’s the idea of assuming a class’s type based on the methods it holds. Say you have 5 different classes, none of which share an inheritance tree. Now let’s say you have a method [...]

Leave a comment Continue Reading →

Return Out Variables Using GetMethod

So I ran into a problem today. I wanted to call a method (TryParse) off a type using relfection, but the catch is that there is an out parameter. At first I though, “Hey, I just give it the type and it will find it. Not so lucky. See when you call GetMethod you have [...]

1 Comment Continue Reading →

Filling a Private Field on a Base Class Using Reflection

Ok here’s the next step in this testing kick. So now you have your test classes that create classes. Swell. Problem is, there are private fields on the base class of whatever class you are creating. So you’re screwed, right? Not really. Now what I am about to do is nothing new. It’s just basically [...]

Leave a comment Continue Reading →