public static XmlRpcServiceInfo CreateServiceInfo(Type type)
{
XmlRpcServiceInfo svcInfo = new XmlRpcServiceInfo();
// extract service info
XmlRpcServiceAttribute svcAttr = (XmlRpcServiceAttribute)
Attribute.GetCustomAttribute(type, typeof(XmlRpcServiceAttribute));
if (svcAttr != null && svcAttr.Description != "")
svcInfo.doc = svcAttr.Description;
if (svcAttr != null && svcAttr.Name != "")
svcInfo.Name = svcAttr.Name;
else
svcInfo.Name = type.Name;
// extract method info
Hashtable methods = new Hashtable();
foreach(Type itf in type.GetInterfaces())
{
XmlRpcServiceAttribute itfAttr = (XmlRpcServiceAttribute)
Attribute.GetCustomAttribute(itf, typeof(XmlRpcServiceAttribute));
if (itfAttr != null)
svcInfo.doc = itfAttr.Description;
#if (!COMPACT_FRAMEWORK)
InterfaceMapping imap = type.GetInterfaceMap(itf);
foreach (MethodInfo mi in imap.InterfaceMethods)
{
ExtractMethodInfo(methods, mi);
}
#else
foreach (MethodInfo mi in itf.GetMethods())
{
ExtractMethodInfo(methods, mi);
}
#endif
}
foreach (MethodInfo mi in type.GetMethods())
{
ArrayList mthds = new ArrayList();
mthds.Add(mi);
MethodInfo curMi = mi;
while (true)
{
MethodInfo baseMi = curMi.GetBaseDefinition();
if (baseMi.DeclaringType == curMi.DeclaringType)
break;
mthds.Insert(0, baseMi);
curMi = baseMi;
}
foreach(MethodInfo mthd in mthds)
{
ExtractMethodInfo(methods, mthd);
}
}
svcInfo.methodInfos = new XmlRpcMethodInfo[methods.Count];
methods.Values.CopyTo(svcInfo.methodInfos, 0);
Array.Sort(svcInfo.methodInfos);
return svcInfo;
}