5 using System.Runtime.InteropServices;
6 using System.Diagnostics;
7 using System.Collections;
8 using System.Reflection;
10 internal class Introspector
13 private static Hashtable introspectors = new Hashtable();
14 private Hashtable interfaceProxies = null;
16 public static Introspector GetIntrospector(Type type)
18 if (!introspectors.Contains(type)) {
19 introspectors[type] = new Introspector(type);
22 return (Introspector) introspectors[type];
25 private Introspector(Type type)
27 interfaceProxies = new Hashtable();
32 private void AddType(Type type)
34 if (type == typeof(object)) {
39 object[] attributes = type.GetCustomAttributes(typeof(InterfaceAttribute), false);
40 if (attributes.Length >= 1) {
41 // This is a D-BUS interface so add it to the hashtable
42 InterfaceProxy interfaceProxy = InterfaceProxy.GetInterface(type);
43 interfaceProxies.Add(interfaceProxy.InterfaceName, interfaceProxy);
46 AddType(type.BaseType);
49 public InterfaceProxy GetInterface(string interfaceName) {
50 if (interfaceProxies.Contains(interfaceName)) {
51 return (InterfaceProxy) interfaceProxies[interfaceName];
57 public Hashtable InterfaceProxies
60 return this.interfaceProxies;
64 public ConstructorInfo Constructor
67 ConstructorInfo ret = this.type.GetConstructor(new Type[0]);
71 return typeof(object).GetConstructor(new Type[0]);
76 public override string ToString()
78 return this.type.ToString();