11
Reflection - classes that assign attributes to code that can be queried at build and at run time
l/* show type and methods of objects obj */
lprivate string ShowType(object obj)
l{
l Type type=obj.GetType();
l StringBuilder Output=new StringBuilder(1000);
l Output.Append("Type "+type.Name+" ("+type.FullName+")\nin "+
l type.Namespace+"\n");
l if (type.BaseType != null)
l Output.Append("Base type "+type.BaseType.Name+"\n");
l if (type.UnderlyingSystemType != null)
l Output.Append(
l "Underlying system type "+type.UnderlyingSystemType.Name+"\n");
l Output.Append("\nPublic Members:\n");
l MemberInfo[] Members=type.GetMembers();
l foreach (MemberInfo Member in Members)
l Output.Append(Member.DeclaringType+
l       "  "+Member.MemberType+":  "+Member.Name +"\n");
l return Output.ToString();
l}