The diagram does not display private methods for the sake of brevity. While I will attemp to keep all diagrams in sync with the actual class, there may be occasions where the diagram is a version or more behind.


The general purpose for the Reflection namespace is to provide a wrapper for the .Net Reflection namespace. Because reflection plays such a key role in creating dynamic, flexible solutions, this namespace is actually foundational to the rest of the Nvigorate framework. Whether or not end users of the framework choose to use the classes provided is actually not the primary concern. Because the use of Reflection usually involves the same tasks, Reflector uses static methods to provide an easy "automated" way to leverage Reflection without the tedium of writing and maintaining the source to do so.

Current Feature Set

  • Dynamically read the value of any property or field (including those inherited) from a target class.
  • Dynamically write a compatible value to any eligible property or field (including those inherited) to a target class.
  • Dynamically invoke any method (static, generic, inherited, etc.) and return the result.
  • Dynamically create generic types at runtime using provided type arguments.
  • Return all custom attributes from a type using any combination of the following criteria:
    • Attribute type
    • Attribute name
    • Member type(s) the attribute applies to
    • Member name
  • List members within a type having custom attribute(s) applied to them which meet any combination of the following criteria:
    • Attribute type
    • Attribute name
    • Member type(s) the attribute applies to
  • Return field-to-value dictionaries for a given instance.
  • Return the field or property value for each instance in a collection.

Potential Features

  • Dynamic generation of types within an assembly based on data necessary to generate the type.
  • Dynamic type assembly cache management which prevents needless regeneration of types created from identical criteria.
  • The ability to generate types on the fly from different input sources. (dataset, xml, source code, etc.)

Technical Specification

Source Code

The Reflector class is currently made up of four separate files: Reflector.cs, Reflector.Attributes.cs, Reflector.Generics.cs and Reflector.Collections.cs. The primary reason for dividing this class into multiple source files (using the partial keyword in the class definition) is to clearly delineate the various functions based on the area they address. The total amount of source lines for the Reflector class is roughly 1800 lines (at this time).

NUnit Tests

Each of the partial class files will have a corresponding test file which contains the NUnit tests necessary to validate functionality and provide full regression testing. Because some functions behave differently based upon input and context, a Unit test should exist for each piece of functionality.


Reflector will use four private members for the sole purpose of controlling the BindingFlags combinations used. The first one will carry the value of the currently designated combination, while the other four will provide the default combinations for each setting.

An additional member will control whether or not the Reflector should perform recursive hierarchy searches when looking for a method, field or property.


Two booleans are required in order to provide the user with sufficient means to control Reflector's behavior based on the BindingFlag combinations. One boolean will reflect what access level Reflector can access while the other will be used to determine whether or not to perform recursive hierarchical searches.


Documentation for this (and other) classes will be made available shortly. In the meantime, unit tests can provide good examples for how this class is used.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.