BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Reflection and DynamicMethods

| by Marcie Jones Follow 0 Followers on Jul 13, 2006. Estimated reading time: 1 minute |

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.

Rate this Article

Adoption Stage
Style

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

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT