Exemplo n.º 1
0
        public Array System__Method__Signature___(string MethodName)
        {
            XmlRpcServiceInfo svcInfo  = XmlRpcServiceInfo.CreateServiceInfo(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");
            }
            var alist = new ArrayList {
                XmlRpcServiceInfo.GetXmlRpcTypeString(mthdInfo.ReturnType)
            };

            foreach (XmlRpcParameterInfo paramInfo in mthdInfo.Parameters)
            {
                alist.Add(XmlRpcServiceInfo.GetXmlRpcTypeString(paramInfo.Type));
            }
            var types    = (string[])alist.ToArray(typeof(string));
            var retalist = new ArrayList {
                types
            };
            Array retarray = retalist.ToArray(typeof(string[]));

            return(retarray);
        }
Exemplo n.º 2
0
        public string[] System__List__Methods___()
        {
            XmlRpcServiceInfo svcInfo = XmlRpcServiceInfo.CreateServiceInfo(GetType());
            var alist = new ArrayList();

            foreach (XmlRpcMethodInfo mthdInfo in svcInfo.Methods)
            {
                if (!mthdInfo.IsHidden)
                {
                    alist.Add(mthdInfo.XmlRpcName);
                }
            }
            return((String[])alist.ToArray(typeof(string)));
        }
Exemplo n.º 3
0
        public string System__Method__Help___(string MethodName)
        {
            XmlRpcServiceInfo svcInfo  = XmlRpcServiceInfo.CreateServiceInfo(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);
        }
Exemplo n.º 4
0
        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, itf);
                }
#else
                foreach (MethodInfo mi in itf.GetMethods())
                {
                    ExtractMethodInfo(methods, mi, itf);
                }
#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, type);
                }
            }
            svcInfo.methodInfos = new XmlRpcMethodInfo[methods.Count];
            methods.Values.CopyTo(svcInfo.methodInfos, 0);
            Array.Sort(svcInfo.methodInfos);
            return(svcInfo);
        }