#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
ref class Reflector
{
public:
void LoadAndReflect(String^ assemblyFileName)
{
Assembly^ assembly = Assembly::LoadFrom(assemblyFileName);
array<Type^>^ types = assembly->GetTypes();
for each (Type^ t in types)
{
Console::WriteLine(t->ToString());
array<MethodInfo^>^ methods = t->GetMethods();
for each (MethodInfo^ method in methods)
{
Console::Write(" {0} {1}(", method->ReturnType->ToString(),method->Name);
array<ParameterInfo^>^ params = method->GetParameters();
for (int i = 0; i < params->Length; i++)
{
ParameterInfo^ param = params[i];
Console::Write("{0} {1}", param->ParameterType->ToString(), param->Name);
if (i < params->Length - 1)
Console::Write(", ");
}
Console::WriteLine(")");
}
}
}
};
int main(array<String^>^ args)
{
Reflector^ r = gcnew Reflector();
for each (String^ s in args)
{
Console::WriteLine("Reflection on {0}", s);
r->LoadAndReflect(s);
}
}
|