Friday, November 18, 2005

.NET Reflection: Real-World Examples

I've recently been looking at .NET reflection, and was not completely surprised that most of the examples out there used simple console applications. I wanted to share some examples I found which show more complex uses of reflection. Feel free to add links to your own examples to the comments on this post.

  1. Brad Wilson : Using Reflection for the Visitor Pattern
    From the Summary: The Gang-of-Four Visitor pattern provides a formalized way to de-couple code using double dispatch. The traditional static-language implementation has limitations that can be overcome with reflection.
  2. Rick Strahl: Implementing two-way Data Binding for ASP.Net Web Forms
    From the Summary: This article discusses ASP.NET v1.x data binding and provides a series of classes which simplify data binding by using reflection. Reflection is used to evaluate the value in the data source and in the web form control and then assigns the value into one or the other depending on whether you are binding or unbinding.
  3. K. Syverstad.: .NET Reflection Example
    This blog post contains a code snippet that uses the Microsoft.SharePoint assembly to create an instance of a SPSite for a NAnt task without creating a compile dependency on the Microsoft.SharePoint dll.

Enjoy!

No comments: