Csharp/C Sharp/Reflection/Interface — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:38, 26 мая 2010
Show Interfaces
<source lang="csharp"> using System; using System.Reflection; class MainClass {
public static void ShowInterfaces(Type t) { Type[] interfaces = t.GetInterfaces(); Console.WriteLine("Implemented Interfaces"); foreach (Type type in interfaces) { Console.WriteLine("Interface : {0}", type.FullName); if (type.IsPublic) Console.WriteLine("Scope: Public"); else Console.WriteLine("Scope: Private"); } }
public static void ShowTypes(string name, Assembly assembly) { Type[] typeArray = assembly.GetTypes(); Console.WriteLine("Assembly Name: {0}", name); foreach (Type type in typeArray) { if (type.IsClass) { ShowInterfaces(type); } } } public static void Main(string[] args) { for (int i = 0; i < args.Length; ++i) { // Get the assemble object (from System.Reflection) Assembly assembly = Assembly.LoadFrom(args[0]); ShowTypes(args[0], assembly); } }
}
</source>