Reflect an assemblyNReflect

This shows how to reflect all public elements of an assembly.

Reflect an assembly

The following code shows how to reflect the contents of an assembly and print out the results:

Example

 1// Do the reflection 
 2NRAssembly nrAssembly;
 3try 
 4{
 5  Reflector reflector = new Reflector();
 6  nrAssembly = reflector.Reflect("MyAssembly.dll");
 7}
 8catch(Exception ex)
 9{
10  Console.WriteLine("Exception while reflecting: " + ex.Message);
11  return;
12}
13 
14// Output the results 
15PrintVisitor printVisitor = new PrintVisitor();
16nrAssembly.Accept(printVisitor);
17 
18RelationshipCreator relationshipCreator = new RelationshipCreator();
19NRRelationships nrRelationships = relationshipCreator.CreateRelationships(nrAssembly);
Note Note
Notice the use of the PrintVisitor which is defined at the demonstration program NReflectRunner which is supplied with NReflect.
Note Note
Also notice the use of the NReflect.RelationshipCreator which is used to find the relations between the reflected entities. The result of this operation is an instance of NReflect.NRRelationships which contains all found relations.
See Also

Reference

Other Resources