The class or structure is code. The data about what members every type has, their names and types, what are the signature of each method — all this is
meta-data.
Take a initialized variable of any type. It always has a method
object.GetType
which returns the object of the class
System.Type
. For a type, you can use
typeof
operator which also returns the instance of the class
System.Type
. Look a this class:
http://msdn.microsoft.com/en-us/library/system.type.aspx[
^], see also
http://en.wikipedia.org/wiki/Type_class[
^].
You will find that all the meta-data is available through this class. It's also possible to instantiate new objects of the type based on the Type's invocation methods, read or modify properties of the instance. All this is called Reflection. See
http://en.wikipedia.org/wiki/Reflection_(computer_science)[
^].
It has many application. Using just meta-data approach one can persist data, generate IU on the fly based on pure data (and meta-data added with the use of .NET
attributes, see
http://msdn.microsoft.com/en-us/library/system.attribute.aspx[
^]). One can load assemblies dynamically (see the class
System.Reflection.Assembly
,
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[
^]) and use it for developing and using plug-ins.
See my past answers explaining a skeleton of plug-in architecture based on Reflection:
Create WPF Application that uses Reloadable Plugins...[
^],
AppDomain refuses to load an assembly[
^],
code generating using CodeDom[
^],
Create WPF Application that uses Reloadable Plugins...[
^].
One can even compile code on the fly and use it immediately in the application, see last two of my links above. Finally, one can even generate (
emit) code on the fly, see
System.Reflection.Emit
,
http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx[
^].
There is a number of CodeProject articles on the interesting topic of
System.Reflection.Emit
, see:
http://www.codeproject.com/search.aspx?doctypeid=1&q=Reflection.Emit[
^].
—SA