4 using System.Collections;
5 using System.Reflection;
7 internal class InterfaceProxy
9 private static Hashtable interfaceProxies = new Hashtable();
10 private Hashtable methods = null;
12 private string interfaceName;
14 private InterfaceProxy(Type type)
16 object[] attributes = type.GetCustomAttributes(typeof(InterfaceAttribute), true);
17 InterfaceAttribute interfaceAttribute = (InterfaceAttribute) attributes[0];
18 this.interfaceName = interfaceAttribute.InterfaceName;
22 private void AddMethods(Type type)
24 this.methods = new Hashtable();
25 foreach (MethodInfo method in type.GetMethods(BindingFlags.Public |
26 BindingFlags.Instance |
27 BindingFlags.DeclaredOnly)) {
28 object[] attributes = method.GetCustomAttributes(typeof(MethodAttribute), true);
29 if (attributes.GetLength(0) > 0) {
30 methods.Add(GetKey(method), method);
36 public static InterfaceProxy GetInterface(Type type)
38 if (!interfaceProxies.Contains(type)) {
39 interfaceProxies[type] = new InterfaceProxy(type);
42 return (InterfaceProxy) interfaceProxies[type];
45 public bool HasMethod(string key)
47 return this.Methods.Contains(key);
50 public MethodInfo GetMethod(string key)
52 return (MethodInfo) this.Methods[key];
55 private string GetKey(MethodInfo method)
57 ParameterInfo[] pars = method.GetParameters();
58 string key = method.Name + " ";
60 foreach (ParameterInfo par in pars) {
62 Type dbusType = Arguments.MatchType(par.ParameterType);
63 key += Arguments.GetCode(dbusType);
70 public Hashtable Methods
77 public string InterfaceName
80 return this.interfaceName;