1 | using System; |
---|
2 | using System.Collections; |
---|
3 | using CookComputing.XmlRpc; |
---|
4 | |
---|
5 | namespace CookComputing.XmlRpc |
---|
6 | { |
---|
7 | public class SystemMethodsBase : MarshalByRefObject |
---|
8 | { |
---|
9 | [XmlRpcMethod("system.listMethods", IntrospectionMethod = true, |
---|
10 | Description = |
---|
11 | "Return an array of all available XML-RPC methods on this Service.")] |
---|
12 | public string[] System__List__Methods___() |
---|
13 | { |
---|
14 | XmlRpcServiceInfo svcInfo = XmlRpcServiceInfo.CreateServiceInfo( |
---|
15 | this.GetType()); |
---|
16 | ArrayList alist = new ArrayList(); |
---|
17 | foreach (XmlRpcMethodInfo mthdInfo in svcInfo.Methods) |
---|
18 | { |
---|
19 | if (!mthdInfo.IsHidden) |
---|
20 | alist.Add(mthdInfo.XmlRpcName); |
---|
21 | } |
---|
22 | return (String[])alist.ToArray(typeof(string)); |
---|
23 | } |
---|
24 | |
---|
25 | [XmlRpcMethod("system.methodSignature", IntrospectionMethod = true, |
---|
26 | Description = |
---|
27 | "Given the name of a method, return an array of legal signatures. " + |
---|
28 | "Each signature is an array of strings. The first item of each " + |
---|
29 | "signature is the return type, and any others items are parameter " + |
---|
30 | "types.")] |
---|
31 | public Array System__Method__Signature___(string MethodName) |
---|
32 | { |
---|
33 | //TODO: support overloaded methods |
---|
34 | XmlRpcServiceInfo svcInfo = XmlRpcServiceInfo.CreateServiceInfo( |
---|
35 | this.GetType()); |
---|
36 | XmlRpcMethodInfo mthdInfo = svcInfo.GetMethod(MethodName); |
---|
37 | if (mthdInfo == null) |
---|
38 | { |
---|
39 | throw new XmlRpcFaultException(880, |
---|
40 | "Request for information on unsupported method"); |
---|
41 | } |
---|
42 | if (mthdInfo.IsHidden) |
---|
43 | { |
---|
44 | throw new XmlRpcFaultException(881, |
---|
45 | "Information not available on this method"); |
---|
46 | } |
---|
47 | //XmlRpcTypes.CheckIsXmlRpcMethod(mi); |
---|
48 | ArrayList alist = new ArrayList(); |
---|
49 | alist.Add(XmlRpcServiceInfo.GetXmlRpcTypeString(mthdInfo.ReturnType)); |
---|
50 | foreach (XmlRpcParameterInfo paramInfo in mthdInfo.Parameters) |
---|
51 | { |
---|
52 | alist.Add(XmlRpcServiceInfo.GetXmlRpcTypeString(paramInfo.Type)); |
---|
53 | } |
---|
54 | string[] types = (string[])alist.ToArray(typeof(string)); |
---|
55 | ArrayList retalist = new ArrayList(); |
---|
56 | retalist.Add(types); |
---|
57 | Array retarray = retalist.ToArray(typeof(string[])); |
---|
58 | return retarray; |
---|
59 | } |
---|
60 | |
---|
61 | [XmlRpcMethod("system.methodHelp", IntrospectionMethod = true, |
---|
62 | Description = |
---|
63 | "Given the name of a method, return a help string.")] |
---|
64 | public string System__Method__Help___(string MethodName) |
---|
65 | { |
---|
66 | //TODO: support overloaded methods? |
---|
67 | XmlRpcServiceInfo svcInfo = XmlRpcServiceInfo.CreateServiceInfo( |
---|
68 | this.GetType()); |
---|
69 | XmlRpcMethodInfo mthdInfo = svcInfo.GetMethod(MethodName); |
---|
70 | if (mthdInfo == null) |
---|
71 | { |
---|
72 | throw new XmlRpcFaultException(880, |
---|
73 | "Request for information on unsupported method"); |
---|
74 | } |
---|
75 | if (mthdInfo.IsHidden) |
---|
76 | { |
---|
77 | throw new XmlRpcFaultException(881, |
---|
78 | "Information not available for this method"); |
---|
79 | } |
---|
80 | return mthdInfo.Doc; |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|