BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Reflection and DynamicMethods

by Marcie Jones on Jul 13, 2006 |

While most .NET developers have heard of reflection, many have not yet implemented reflection in their applications to its fullest potential.  Essentially, reflection is the run-time examination of an object's members.  Zach Smith's reflection article on TechRepublic provides sample code and a few suggested uses for reflection:

Reflection can be used to implement a wide range of functionality. Most serialization engines use reflection to extract data from the objects that need to be serialized. Reflection can also be used to create customizable application architectures through the use of plug-in modules. Many Object Relation Modeling (ORM) solutions also take advantage of reflection to implement dynamic mapping functionality

A few other suggestions:  code generation, accessing private members of 3rd party objects(such as Microsoft controls), and dynamically generating unit tests based on an object's methods.  The possible uses of reflection are endless.  How many more can you come up with?

In addition, with .NET 2.0 provides a new DynamicMethod class in the System.Reflection.Emit namespace that provides even faster access to an object's properties or fields.  This class allows direct access to the Intermediate Language (IL) generated for the object, with much faster execution than traditional reflection techniques in .NET 1.x.  Read more about these techniques in Fast Dynamic Property/Field Accessors.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT