예제 #1
0
        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);
        }
예제 #2
0
        static void ExtractMethodInfo(Hashtable methods, MethodInfo mi)
        {
            XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute)
                                         Attribute.GetCustomAttribute(mi,
                                                                      typeof(XmlRpcMethodAttribute));

            if (attr == null)
            {
                return;
            }

            XmlRpcMethodInfo mthdInfo = (XmlRpcMethodInfo)methods[mi.Name];

            if (mthdInfo == null)
            {
                mthdInfo = new XmlRpcMethodInfo();
                methods.Add(mi.Name, mthdInfo);
            }

            mthdInfo.MethodInfo = mi;
            mthdInfo.XmlRpcName = GetXmlRpcMethodName(mi);
            mthdInfo.MiName     = mi.Name;
            mthdInfo.Doc        = attr.Description;
            mthdInfo.IsHidden   = attr.IntrospectionMethod | attr.Hidden;
            // extract parameters information
            ArrayList parmList = new ArrayList();

            ParameterInfo[] parms = mi.GetParameters();
            foreach (ParameterInfo parm in parms)
            {
                XmlRpcParameterInfo parmInfo = new XmlRpcParameterInfo();
                parmInfo.Name       = parm.Name;
                parmInfo.Type       = parm.ParameterType;
                parmInfo.XmlRpcType = GetXmlRpcTypeString(parm.ParameterType);
                // retrieve optional attributed info
                parmInfo.Doc = "";
                XmlRpcParameterAttribute pattr = (XmlRpcParameterAttribute)
                                                 Attribute.GetCustomAttribute(parm,
                                                                              typeof(XmlRpcParameterAttribute));
                if (pattr != null)
                {
                    parmInfo.Doc        = pattr.Description;
                    parmInfo.XmlRpcName = pattr.Name;
                }
                parmList.Add(parmInfo);
            }
            mthdInfo.Parameters = (XmlRpcParameterInfo[])
                                  parmList.ToArray(typeof(XmlRpcParameterInfo));
            // extract return type information
            mthdInfo.ReturnType       = mi.ReturnType;
            mthdInfo.ReturnXmlRpcType = GetXmlRpcTypeString(mi.ReturnType);
            object[] orattrs = mi.ReturnTypeCustomAttributes.GetCustomAttributes(
                typeof(XmlRpcReturnValueAttribute), false);
            if (orattrs.Length > 0)
            {
                mthdInfo.ReturnDoc = ((XmlRpcReturnValueAttribute)orattrs[0]).Description;
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
    static void ExtractMethodInfo(Dictionary<string, XmlRpcMethodInfo> methods, 
      MethodInfo mi, Type type)
    {
      XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute)
        Attribute.GetCustomAttribute(mi,
        typeof(XmlRpcMethodAttribute));
      if (attr == null)
        return;
      XmlRpcMethodInfo mthdInfo = new XmlRpcMethodInfo();
      mthdInfo.MethodInfo = mi;
      mthdInfo.XmlRpcName = GetXmlRpcMethodName(mi);
      mthdInfo.MiName = mi.Name;
      mthdInfo.Doc = attr.Description;
      mthdInfo.IsHidden = attr.IntrospectionMethod | attr.Hidden;
      // extract parameters information
      var parmList = new List<XmlRpcParameterInfo>();
      ParameterInfo[] parms = mi.GetParameters();
      foreach (ParameterInfo parm in parms)
      {
        XmlRpcParameterInfo parmInfo = new XmlRpcParameterInfo();
        parmInfo.Name = parm.Name;
        parmInfo.Type = parm.ParameterType;
        parmInfo.XmlRpcType = GetXmlRpcTypeString(parm.ParameterType);
        // retrieve optional attributed info
        parmInfo.Doc = "";
        XmlRpcParameterAttribute pattr = (XmlRpcParameterAttribute)
          Attribute.GetCustomAttribute(parm,
          typeof(XmlRpcParameterAttribute));
        if (pattr != null)
        {
          parmInfo.Doc = pattr.Description;
          parmInfo.XmlRpcName = pattr.Name;
        }
        parmInfo.IsParams = Attribute.IsDefined(parm,
          typeof(ParamArrayAttribute));
        parmList.Add(parmInfo);
      }
      mthdInfo.Parameters = parmList.ToArray();
      // extract return type information
      mthdInfo.ReturnType = mi.ReturnType;
      mthdInfo.ReturnXmlRpcType = GetXmlRpcTypeString(mi.ReturnType);
      object[] orattrs = mi.ReturnTypeCustomAttributes.GetCustomAttributes(
        typeof(XmlRpcReturnValueAttribute), false);
      if (orattrs.Length > 0)
      {
        mthdInfo.ReturnDoc = ((XmlRpcReturnValueAttribute)orattrs[0]).Description;
      }

      if (methods.ContainsKey(mthdInfo.XmlRpcName))
      {
        throw new XmlRpcDupXmlRpcMethodNames(String.Format("Method "
          + "{0} in type {1} has duplicate XmlRpc method name {2}",
          mi.Name, type.Name, mthdInfo.XmlRpcName));
      }
      else
        methods.Add(mthdInfo.XmlRpcName, mthdInfo);
    }
예제 #5
0
        private static void WriteMethod(
            HtmlTextWriter wrtr, 
            XmlRpcMethodInfo mthdInfo,
            IList structs)
        {
            wrtr.WriteFullBeginTag("span");
            wrtr.WriteLine();
            wrtr.WriteFullBeginTag("h2");
            wrtr.WriteBeginTag("a");
            wrtr.WriteAttribute("name", "#" + mthdInfo.XmlRpcName);
            wrtr.Write(HtmlTextWriter.TagRightChar);
            wrtr.Write("method " + mthdInfo.XmlRpcName);
            wrtr.WriteEndTag("a");
            wrtr.WriteEndTag("h2");
            wrtr.WriteLine();

            if (!string.IsNullOrEmpty(mthdInfo.Doc))
            {
                wrtr.WriteBeginTag("p");
                wrtr.WriteAttribute("class", "intro");
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write(mthdInfo.Doc);
                wrtr.WriteEndTag("p");
                wrtr.WriteLine();
            }

            wrtr.WriteFullBeginTag("h3");
            wrtr.Write("Parameters");
            wrtr.WriteEndTag("h3");
            wrtr.WriteLine();

            wrtr.WriteBeginTag("table");
            wrtr.WriteAttribute("cellspacing", "0");
            wrtr.WriteAttribute("cellpadding", "5");
            wrtr.WriteAttribute("width", "90%");
            wrtr.Write(HtmlTextWriter.TagRightChar);

            if (mthdInfo.Parameters.Length > 0)
            {
                foreach (var parInfo in mthdInfo.Parameters)
                {
                    wrtr.WriteFullBeginTag("tr");
                    wrtr.WriteBeginTag("td");
                    wrtr.WriteAttribute("width", "33%");
                    wrtr.Write(HtmlTextWriter.TagRightChar);
                    WriteType(wrtr, parInfo.Type, parInfo.IsParams, structs);
                    wrtr.WriteEndTag("td");

                    wrtr.WriteFullBeginTag("td");
                    if (string.IsNullOrEmpty(parInfo.Doc))
                        wrtr.Write(parInfo.Name);
                    else
                    {
                        wrtr.Write(parInfo.Name);
                        wrtr.Write(" - ");
                        wrtr.Write(parInfo.Doc);
                    }

                    wrtr.WriteEndTag("td");
                    wrtr.WriteEndTag("tr");
                }
            }
            else
            {
                wrtr.WriteFullBeginTag("tr");
                wrtr.WriteBeginTag("td");
                wrtr.WriteAttribute("width", "33%");
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write("none");
                wrtr.WriteEndTag("td");
                wrtr.WriteFullBeginTag("td");
                wrtr.Write("&nbsp;");
                wrtr.WriteEndTag("td");
                wrtr.WriteEndTag("tr");
            }

            wrtr.WriteEndTag("table");
            wrtr.WriteLine();
            wrtr.WriteFullBeginTag("h3");
            wrtr.Write("Return Value");
            wrtr.WriteEndTag("h3");
            wrtr.WriteLine();

            wrtr.WriteBeginTag("table");
            wrtr.WriteAttribute("cellspacing", "0");
            wrtr.WriteAttribute("cellpadding", "5");
            wrtr.WriteAttribute("width", "90%");
            wrtr.Write(HtmlTextWriter.TagRightChar);

            wrtr.WriteFullBeginTag("tr");

            wrtr.WriteBeginTag("td");
            wrtr.WriteAttribute("width", "33%");
            wrtr.Write(HtmlTextWriter.TagRightChar);
            WriteType(wrtr, mthdInfo.ReturnType, false, structs);
            wrtr.WriteEndTag("td");

            wrtr.WriteFullBeginTag("td");

            if (!string.IsNullOrEmpty(mthdInfo.ReturnDoc))
                wrtr.Write(mthdInfo.ReturnDoc);
            else
                wrtr.Write("&nbsp;");

            wrtr.WriteEndTag("td");

            wrtr.WriteEndTag("tr");

            wrtr.WriteEndTag("table");
            wrtr.WriteLine();

            wrtr.WriteEndTag("span");
            wrtr.WriteLine();
        }
예제 #6
0
        static void WriteMethod(
            HtmlTextWriter wrtr,
            XmlRpcMethodInfo mthdInfo,
            ArrayList structs)
        {
            wrtr.WriteFullBeginTag("span");
            wrtr.WriteLine();
            wrtr.WriteFullBeginTag("h2");
            wrtr.WriteBeginTag("a");
            wrtr.WriteAttribute("name", "#" + mthdInfo.XmlRpcName);
            wrtr.Write(HtmlTextWriter.TagRightChar);
            wrtr.Write("method " + mthdInfo.XmlRpcName);
            wrtr.WriteEndTag("a");
            wrtr.WriteEndTag("h2");
            wrtr.WriteLine();

            if (mthdInfo.Doc != "")
            {
                wrtr.WriteBeginTag("p");
                wrtr.WriteAttribute("class", "intro");
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write(mthdInfo.Doc);
                wrtr.WriteEndTag("p");
                wrtr.WriteLine();
            }

            wrtr.WriteFullBeginTag("h3");
            wrtr.Write("Parameters");
            wrtr.WriteEndTag("h3");
            wrtr.WriteLine();

            wrtr.WriteBeginTag("table");
            wrtr.WriteAttribute("cellspacing", "0");
            wrtr.WriteAttribute("cellpadding", "5");
            wrtr.WriteAttribute("width", "90%");
            wrtr.Write(HtmlTextWriter.TagRightChar);

            if (mthdInfo.Parameters.Length > 0)
            {
                foreach (XmlRpcParameterInfo parInfo in mthdInfo.Parameters)
                {
                    wrtr.WriteFullBeginTag("tr");
                    wrtr.WriteBeginTag("td");
                    wrtr.WriteAttribute("width", "33%");
                    wrtr.Write(HtmlTextWriter.TagRightChar);
                    WriteType(wrtr, parInfo.Type, structs);
                    wrtr.WriteEndTag("td");

                    wrtr.WriteFullBeginTag("td");
                    if (parInfo.Doc == "")
                    {
                        wrtr.Write(parInfo.Name);
                    }
                    else
                    {
                        wrtr.Write(parInfo.Name);
                        wrtr.Write(" - ");
                        wrtr.Write(parInfo.Doc);
                    }
                    wrtr.WriteEndTag("td");
                    wrtr.WriteEndTag("tr");
                }
            }
            else
            {
                wrtr.WriteFullBeginTag("tr");
                wrtr.WriteBeginTag("td");
                wrtr.WriteAttribute("width", "33%");
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write("none");
                wrtr.WriteEndTag("td");
                wrtr.WriteFullBeginTag("td");
                wrtr.Write("&nbsp;");
                wrtr.WriteEndTag("td");
                wrtr.WriteEndTag("tr");
            }
            wrtr.WriteEndTag("table");
            wrtr.WriteLine();
            wrtr.WriteFullBeginTag("h3");
            wrtr.Write("Return Value");
            wrtr.WriteEndTag("h3");
            wrtr.WriteLine();


            wrtr.WriteBeginTag("table");
            wrtr.WriteAttribute("cellspacing", "0");
            wrtr.WriteAttribute("cellpadding", "5");
            wrtr.WriteAttribute("width", "90%");
            wrtr.Write(HtmlTextWriter.TagRightChar);

            wrtr.WriteFullBeginTag("tr");

            wrtr.WriteBeginTag("td");
            wrtr.WriteAttribute("width", "33%");
            wrtr.Write(HtmlTextWriter.TagRightChar);
            WriteType(wrtr, mthdInfo.ReturnType, structs);
            wrtr.WriteEndTag("td");

            wrtr.WriteFullBeginTag("td");
            if (mthdInfo.ReturnDoc != "")
            {
                wrtr.Write(mthdInfo.ReturnDoc);
            }
            else
            {
                wrtr.Write("&nbsp;");
            }
            wrtr.WriteEndTag("td");

            wrtr.WriteEndTag("tr");

            wrtr.WriteEndTag("table");
            wrtr.WriteLine();

            wrtr.WriteEndTag("span");
            wrtr.WriteLine();
        }
예제 #7
0
        static void ExtractMethodInfo(Dictionary <string, XmlRpcMethodInfo> methods,
                                      MethodInfo mi, Type type)
        {
            XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute)
                                         Attribute.GetCustomAttribute(mi,
                                                                      typeof(XmlRpcMethodAttribute));

            if (attr == null)
            {
                return;
            }
            XmlRpcMethodInfo mthdInfo = new XmlRpcMethodInfo();

            mthdInfo.MethodInfo = mi;
            mthdInfo.XmlRpcName = XmlRpcTypeInfo.GetXmlRpcMethodName(mi);
            mthdInfo.MiName     = mi.Name;
            mthdInfo.Doc        = attr.Description;
            mthdInfo.IsHidden   = attr.IntrospectionMethod | attr.Hidden;
            // extract parameters information
            var parmList = new List <XmlRpcParameterInfo>();

            ParameterInfo[] parms = mi.GetParameters();
            foreach (ParameterInfo parm in parms)
            {
                XmlRpcParameterInfo parmInfo = new XmlRpcParameterInfo();
                parmInfo.Name       = parm.Name;
                parmInfo.Type       = parm.ParameterType;
                parmInfo.XmlRpcType = XmlRpcTypeInfo.GetXmlRpcTypeString(parm.ParameterType);
                // retrieve optional attributed info
                parmInfo.Doc = "";
                XmlRpcParameterAttribute pattr = (XmlRpcParameterAttribute)
                                                 Attribute.GetCustomAttribute(parm,
                                                                              typeof(XmlRpcParameterAttribute));
                if (pattr != null)
                {
                    parmInfo.Doc        = pattr.Description;
                    parmInfo.XmlRpcName = pattr.Name;
                }
                parmInfo.IsParams = Attribute.IsDefined(parm,
                                                        typeof(ParamArrayAttribute));
                parmList.Add(parmInfo);
            }
            mthdInfo.Parameters = parmList.ToArray();
            // extract return type information
            mthdInfo.ReturnType       = mi.ReturnType;
            mthdInfo.ReturnXmlRpcType = XmlRpcTypeInfo.GetXmlRpcTypeString(mi.ReturnType);
            object[] orattrs = mi.ReturnTypeCustomAttributes.GetCustomAttributes(
                typeof(XmlRpcReturnValueAttribute), false);
            if (orattrs.Length > 0)
            {
                mthdInfo.ReturnDoc = ((XmlRpcReturnValueAttribute)orattrs[0]).Description;
            }

            if (methods.ContainsKey(mthdInfo.XmlRpcName))
            {
                throw new XmlRpcDupXmlRpcMethodNames(String.Format("Method "
                                                                   + "{0} in type {1} has duplicate XmlRpc method name {2}",
                                                                   mi.Name, type.Name, mthdInfo.XmlRpcName));
            }
            else
            {
                methods.Add(mthdInfo.XmlRpcName, mthdInfo);
            }
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            XmlRpcMethodInfo xmi = (XmlRpcMethodInfo)obj;

            return(this.xmlRpcName.CompareTo(xmi.xmlRpcName));
        }
예제 #9
0
        private static void ExtractMethodInfo(Hashtable methods, MethodInfo mi, Type type)
        {
            var attr = (XmlRpcMethodAttribute)
                       Attribute.GetCustomAttribute(mi,
                                                    typeof(XmlRpcMethodAttribute));

            if (attr == null)
            {
                return;
            }
            var mthdInfo = new XmlRpcMethodInfo
            {
                MethodInfo = mi,
                XmlRpcName = GetXmlRpcMethodName(mi),
                MiName     = mi.Name,
                Doc        = attr.Description,
                IsHidden   = attr.IntrospectionMethod | attr.Hidden
            };
            // extract parameters information
            var parmList = new List <XmlRpcParameterInfo>();
            var parms    = mi.GetParameters();

            foreach (var parm in parms)
            {
                var parmInfo = new XmlRpcParameterInfo
                {
                    Name       = parm.Name,
                    Type       = parm.ParameterType,
                    XmlRpcType = GetXmlRpcTypeString(parm.ParameterType),
                    // retrieve optional attributed info
                    Doc = ""
                };
                var pattr = (XmlRpcParameterAttribute)
                            Attribute.GetCustomAttribute(parm,
                                                         typeof(XmlRpcParameterAttribute));
                if (pattr != null)
                {
                    parmInfo.Doc        = pattr.Description;
                    parmInfo.XmlRpcName = pattr.Name;
                }
                parmInfo.IsParams = Attribute.IsDefined(parm,
                                                        typeof(ParamArrayAttribute));
                parmList.Add(parmInfo);
            }
            mthdInfo.Parameters = parmList.ToArray();
            // extract return type information
            mthdInfo.ReturnType       = mi.ReturnType;
            mthdInfo.ReturnXmlRpcType = GetXmlRpcTypeString(mi.ReturnType);
            var orattrs = mi.ReturnTypeCustomAttributes.GetCustomAttributes(
                typeof(XmlRpcReturnValueAttribute), false);

            if (orattrs.Length > 0)
            {
                mthdInfo.ReturnDoc = ((XmlRpcReturnValueAttribute)orattrs[0]).Description;
            }

            if (methods[mthdInfo.XmlRpcName] != null)
            {
                throw new XmlRpcDupXmlRpcMethodNames(string.Format("Method "
                                                                   + "{0} in type {1} has duplicate XmlRpc method name {2}",
                                                                   mi.Name, type.Name, mthdInfo.XmlRpcName));
            }
            else
            {
                methods.Add(mthdInfo.XmlRpcName, mthdInfo);
            }
        }
예제 #10
0
        static void ExtractMethodInfo(Hashtable methods, MethodInfo mi)
        {
            XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute)
            Attribute.GetCustomAttribute(mi,
            typeof(XmlRpcMethodAttribute));
              if (attr == null)
            return;

              XmlRpcMethodInfo mthdInfo = (XmlRpcMethodInfo)methods[mi.Name];
              if (mthdInfo == null)
              {
            mthdInfo = new XmlRpcMethodInfo();
            methods.Add(mi.Name, mthdInfo);
              }

              mthdInfo.MethodInfo = mi;
              mthdInfo.XmlRpcName = GetXmlRpcMethodName(mi);
              mthdInfo.MiName = mi.Name;
              mthdInfo.Doc = attr.Description;
              mthdInfo.IsHidden = attr.IntrospectionMethod | attr.Hidden;
              // extract parameters information
              ArrayList parmList = new ArrayList();
              ParameterInfo[] parms = mi.GetParameters();
              foreach (ParameterInfo parm in parms)
              {
            XmlRpcParameterInfo parmInfo = new XmlRpcParameterInfo();
            parmInfo.Name = parm.Name;
            parmInfo.Type = parm.ParameterType;
            parmInfo.XmlRpcType = GetXmlRpcTypeString(parm.ParameterType);
            // retrieve optional attributed info
            parmInfo.Doc = "";
            XmlRpcParameterAttribute pattr = (XmlRpcParameterAttribute)
              Attribute.GetCustomAttribute(parm,
              typeof(XmlRpcParameterAttribute));
            if (pattr != null)
            {
              parmInfo.Doc = pattr.Description;
              parmInfo.XmlRpcName = pattr.Name;
            }
            parmInfo.IsParams = Attribute.IsDefined(parm,
              typeof(ParamArrayAttribute));
            parmList.Add(parmInfo);
              }
              mthdInfo.Parameters = (XmlRpcParameterInfo[])
            parmList.ToArray(typeof(XmlRpcParameterInfo));
              // extract return type information
              mthdInfo.ReturnType = mi.ReturnType;
              mthdInfo.ReturnXmlRpcType = GetXmlRpcTypeString(mi.ReturnType);
              object[] orattrs = mi.ReturnTypeCustomAttributes.GetCustomAttributes(
            typeof(XmlRpcReturnValueAttribute), false);
              if (orattrs.Length > 0)
              {
            mthdInfo.ReturnDoc = ((XmlRpcReturnValueAttribute)orattrs[0]).Description;
              }
        }