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