コード例 #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
ファイル: XmlRpcServiceInfo.cs プロジェクト: adzerk/OpenX.Net
    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
      var methods = new Dictionary<string, XmlRpcMethodInfo>();

      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())
      {
        var mthds = new List<MethodInfo>();
        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;
    }
コード例 #3
0
        public static void WriteDoc(HtmlTextWriter wrtr, Type type)
        {
            XmlRpcServiceInfo svcInfo = XmlRpcServiceInfo.CreateServiceInfo(type);

            wrtr.WriteFullBeginTag("html");
            wrtr.WriteLine();
            WriteHead(wrtr, svcInfo.Name);
            wrtr.WriteLine();
            WriteBody(wrtr, type);
            wrtr.WriteEndTag("html");
        }
コード例 #4
0
        public static XmlRpcServiceInfo CreateServiceInfo(Type type)
        {
            var svcInfo = new XmlRpcServiceInfo();
            // extract service info
            var svcAttr = Attribute.GetCustomAttribute(type, typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;
            if (svcAttr != null && !string.IsNullOrEmpty(svcAttr.Description))
                svcInfo.Doc = svcAttr.Description;

            if (svcAttr != null && !string.IsNullOrEmpty(svcAttr.Name))
                svcInfo.Name = svcAttr.Name;
            else
                svcInfo.Name = type.Name;

            // extract method info
            var methods = new Dictionary<string, XmlRpcMethodInfo>();

            foreach (Type itf in type.GetInterfaces())
            {
                var itfAttr = Attribute.GetCustomAttribute(itf, typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;
                if (itfAttr != null)
                    svcInfo.Doc = itfAttr.Description;

                var imap = type.GetInterfaceMap(itf);
                foreach (var mi in imap.InterfaceMethods)
                    ExtractMethodInfo(methods, mi, itf);
            }

            foreach (var mi in type.GetMethods())
            {
                var mthds = new List<MethodInfo>();
                mthds.Add(mi);

                var curMi = mi;
                while (true)
                {
                    var baseMi = curMi.GetBaseDefinition();
                    if (baseMi.DeclaringType == curMi.DeclaringType)
                        break;

                    mthds.Insert(0, baseMi);
                    curMi = baseMi;
                }

                foreach (var 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;
        }
コード例 #5
0
 public override void Add(object key, object value)
 {
     if (!(key is string))
     {
         throw new ArgumentException("XmlRpcStruct key must be a string.");
     }
     if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType())
         == XmlRpcType.tInvalid)
     {
         throw new ArgumentException(String.Format(
                                         "Type {0} cannot be mapped to an XML-RPC type", value.GetType()));
     }
     base.Add(key, value);
 }
コード例 #6
0
ファイル: XmlRpcStruct.cs プロジェクト: zanybaka/ljArchive
 // TODO: add constructor with params args
 public override void Add(object key, object value)
 {
     if (!(key is string))
     {
         throw new Exception();
     }
     if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType())
         == XmlRpcType.tInvalid)
     {
         //!! include value type in message?
         throw new Exception();
     }
     base.Add(key, value);
 }
コード例 #7
0
        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)));
        }
コード例 #8
0
        Header[] GetChannelHeaders(
            ITransportHeaders requestHeaders,
            XmlRpcRequest xmlRpcReq,
            Type svcType)
        {
            string            requestUri = (string)requestHeaders["__RequestUri"];
            XmlRpcServiceInfo svcInfo    = XmlRpcServiceInfo.CreateServiceInfo(svcType);
            ArrayList         hdrList    = new ArrayList();

            hdrList.Add(new Header("__Uri", requestUri));
            hdrList.Add(new Header("__TypeName", svcType.AssemblyQualifiedName));
            hdrList.Add(new Header("__MethodName",
                                   svcInfo.GetMethodName(xmlRpcReq.method)));
            hdrList.Add(new Header("__Args", xmlRpcReq.args));
            return((Header[])hdrList.ToArray(typeof(Header)));
        }
コード例 #9
0
        public override void Add(object key, object value)
        {
            if (!(key is string))
            {
                throw new ArgumentException("XmlRpcStruct key must be a string.");
            }

            if (value != null && XmlRpcServiceInfo.GetXmlRpcType(value.GetType())
                == XmlRpcType.tInvalid)
            {
                throw new ArgumentException($"Type {value.GetType()} cannot be mapped to an XML-RPC type");
            }

            base.Add(key, value);
            _keys.Add(key);
            _values.Add(value);
        }
コード例 #10
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);
        }
コード例 #11
0
 public override object this[object key]
 {
     get => base[key];
     set
     {
         if (!(key is string))
         {
             throw new ArgumentException("XmlRpcStruct key must be a string.");
         }
         if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType())
             == XmlRpcType.tInvalid)
         {
             throw new ArgumentException($"Type {value.GetType()} cannot be mapped to an XML-RPC type");
         }
         base[key] = value;
         _keys.Add(key);
         _values.Add(value);
     }
 }
コード例 #12
0
 public override object this[object key]
 {
     get
     {
         return(base[key]);
     }
     set
     {
         if (!(key is string))
         {
             throw new ArgumentException("XmlRpcStruct key must be a string.");
         }
         if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType())
             == XmlRpcType.tInvalid)
         {
             throw new ArgumentException(String.Format(
                                             "Type {0} cannot be mapped to an XML-RPC type", value.GetType()));
         }
         base[key] = value;
     }
 }
コード例 #13
0
        public static XmlRpcServiceInfo CreateServiceInfo(Type type)
        {
            var svcInfo = new XmlRpcServiceInfo();
            // extract service info
            var svcAttr = Attribute.GetCustomAttribute(type, typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;

            if (svcAttr != null && !string.IsNullOrEmpty(svcAttr.Description))
            {
                svcInfo.Doc = svcAttr.Description;
            }

            if (svcAttr != null && !string.IsNullOrEmpty(svcAttr.Name))
            {
                svcInfo.Name = svcAttr.Name;
            }
            else
            {
                svcInfo.Name = type.Name;
            }

            // extract method info
            var methods = new Dictionary <string, XmlRpcMethodInfo>();

            foreach (Type itf in type.GetInterfaces())
            {
                var itfAttr = Attribute.GetCustomAttribute(itf, typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;
                if (itfAttr != null)
                {
                    svcInfo.Doc = itfAttr.Description;
                }

                var imap = type.GetInterfaceMap(itf);
                foreach (var mi in imap.InterfaceMethods)
                {
                    ExtractMethodInfo(methods, mi, itf);
                }
            }

            foreach (var mi in type.GetMethods())
            {
                var mthds = new List <MethodInfo>();
                mthds.Add(mi);

                var curMi = mi;
                while (true)
                {
                    var baseMi = curMi.GetBaseDefinition();
                    if (baseMi.DeclaringType == curMi.DeclaringType)
                    {
                        break;
                    }

                    mthds.Insert(0, baseMi);
                    curMi = baseMi;
                }

                foreach (var 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);
        }
コード例 #14
0
        static void WriteType(
            HtmlTextWriter wrtr,
            Type type,
            ArrayList structs)
        {
            // TODO: following is hack for case when type is Object
            string xmlRpcType;

            if (type != typeof(Object))
            {
                xmlRpcType = XmlRpcServiceInfo.GetXmlRpcTypeString(type);
            }
            else
            {
                xmlRpcType = "any";
            }
            wrtr.Write(xmlRpcType);
            if (xmlRpcType == "struct" && type != typeof(XmlRpcStruct))
            {
                if (!structs.Contains(type))
                {
                    structs.Add(type);
                }
                wrtr.Write(" ");
                wrtr.WriteBeginTag("a");
                wrtr.WriteAttribute("href", "#" + type.Name);
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write(type.Name);
                wrtr.WriteEndTag("a");
            }
            else if (xmlRpcType == "array")
            {
                string[] checkSingleDim = Regex.Split(type.FullName, "\\[\\]$");
                if (checkSingleDim.Length > 1) // single dim array
                {
                    Type     elemType     = null;
                    Assembly asmbly       = type.Assembly;
                    string[] asmblyName   = asmbly.FullName.Split(',');
                    string   elemTypeName = checkSingleDim[0] + ", " + asmblyName[0];
                    elemType = Type.GetType(elemTypeName);

                    wrtr.Write(" of ");
                    string elemXmlRpcType
                        = XmlRpcServiceInfo.GetXmlRpcTypeString(elemType);
                    wrtr.Write(elemXmlRpcType);

                    if (elemXmlRpcType == "struct" && elemType != typeof(XmlRpcStruct))
                    {
                        if (!structs.Contains(elemType))
                        {
                            structs.Add(elemType);
                        }
                        wrtr.Write(" ");
                        wrtr.WriteBeginTag("a");
                        wrtr.WriteAttribute("href", "#" + elemType.Name);
                        wrtr.Write(HtmlTextWriter.TagRightChar);
                        wrtr.Write(elemType.Name);
                        wrtr.WriteEndTag("a");
                    }
                }
            }
        }
コード例 #15
0
        public void DerivedInterfaces()
        {
            XmlRpcServiceInfo svcinfo = XmlRpcServiceInfo.CreateServiceInfo(typeof(FooBar));

            Assert.AreEqual(2, svcinfo.Methods.Length);
        }
コード例 #16
0
        public static void WriteType(
            HtmlTextWriter wrtr,
            Type type)
        {
            ArrayList structs = new ArrayList();

            wrtr.WriteBeginTag("div");
            wrtr.WriteAttribute("id", "content");
            wrtr.Write(HtmlTextWriter.TagRightChar);
            wrtr.WriteLine();

            XmlRpcServiceInfo svcInfo =
                XmlRpcServiceInfo.CreateServiceInfo(type);

            wrtr.WriteBeginTag("p");
            wrtr.WriteAttribute("class", "heading1");
            wrtr.Write(HtmlTextWriter.TagRightChar);
            wrtr.Write(svcInfo.Name);
            wrtr.WriteEndTag("p");
            wrtr.WriteFullBeginTag("br");
            wrtr.WriteEndTag("br");
            wrtr.WriteLine();

            if (svcInfo.Doc != "")
            {
                wrtr.WriteBeginTag("p");
                wrtr.WriteAttribute("class", "intro");
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write(svcInfo.Doc);
                wrtr.WriteEndTag("p");
                wrtr.WriteLine();
            }
            wrtr.WriteBeginTag("p");
            wrtr.WriteAttribute("class", "intro");
            wrtr.Write(HtmlTextWriter.TagRightChar);
            wrtr.Write("The following methods are supported:");
            wrtr.WriteEndTag("p");
            wrtr.WriteLine();

            wrtr.WriteFullBeginTag("ul");
            wrtr.WriteLine();
            foreach (XmlRpcMethodInfo mthdInfo in svcInfo.Methods)
            {
                if (!mthdInfo.IsHidden)
                {
                    wrtr.WriteFullBeginTag("li");
                    wrtr.WriteBeginTag("a");
                    wrtr.WriteAttribute("href", "#" + mthdInfo.XmlRpcName);
                    wrtr.Write(HtmlTextWriter.TagRightChar);
                    wrtr.Write(mthdInfo.XmlRpcName);
                    wrtr.WriteEndTag("a");
                    wrtr.WriteEndTag("li");
                    wrtr.WriteLine();
                }
            }

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

            foreach (XmlRpcMethodInfo mthdInfo in svcInfo.Methods)
            {
                if (mthdInfo.IsHidden == false)
                {
                    WriteMethod(wrtr, mthdInfo, structs);
                }
            }

            for (int j = 0; j < structs.Count; j++)
            {
                WriteStruct(wrtr, structs[j] as Type, structs);
            }

            wrtr.WriteEndTag("div");
            wrtr.WriteLine();
        }
コード例 #17
0
 public void DupXmlRpcNames()
 {
     XmlRpcServiceInfo svcinfo = XmlRpcServiceInfo.CreateServiceInfo(typeof(IDupXmlRpcNames));
 }
コード例 #18
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
            var methods = new Dictionary <string, XmlRpcMethodInfo>();

            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())
            {
                var mthds = new List <MethodInfo>();
                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);
        }
コード例 #19
0
        static void WriteType(
            HtmlTextWriter wrtr,
            Type type,
            bool isparams,
            ArrayList structs)
        {
            // TODO: following is hack for case when type is Object
            string xmlRpcType;

            if (!isparams)
            {
                if (type != typeof(Object))
                {
                    xmlRpcType = XmlRpcServiceInfo.GetXmlRpcTypeString(type);
                }
                else
                {
                    xmlRpcType = "any";
                }
            }
            else
            {
                xmlRpcType = "varargs";
            }
            wrtr.Write(xmlRpcType);
            if (xmlRpcType == "struct" && type != typeof(XmlRpcStruct))
            {
                if (!structs.Contains(type))
                {
                    structs.Add(type);
                }
                wrtr.Write(" ");
                wrtr.WriteBeginTag("a");
                wrtr.WriteAttribute("href", "#" + type.Name);
                wrtr.Write(HtmlTextWriter.TagRightChar);
                wrtr.Write(type.Name);
                wrtr.WriteEndTag("a");
            }
            else if (xmlRpcType == "array" || xmlRpcType == "varargs")
            {
                if (type.GetArrayRank() == 1) // single dim array
                {
                    wrtr.Write(" of ");
                    Type   elemType = type.GetElementType();
                    string elemXmlRpcType;
                    if (elemType != typeof(Object))
                    {
                        elemXmlRpcType = XmlRpcServiceInfo.GetXmlRpcTypeString(elemType);
                    }
                    else
                    {
                        elemXmlRpcType = "any";
                    }
                    wrtr.Write(elemXmlRpcType);
                    if (elemXmlRpcType == "struct" && elemType != typeof(XmlRpcStruct))
                    {
                        if (!structs.Contains(elemType))
                        {
                            structs.Add(elemType);
                        }
                        wrtr.Write(" ");
                        wrtr.WriteBeginTag("a");
                        wrtr.WriteAttribute("href", "#" + elemType.Name);
                        wrtr.Write(HtmlTextWriter.TagRightChar);
                        wrtr.Write(elemType.Name);
                        wrtr.WriteEndTag("a");
                    }
                }
            }
        }
コード例 #20
0
        public XmlRpcRequest DeserializeRequest(XmlReader rdr, Type svcType)
        {
            try
            {
                XmlRpcRequest      request = new XmlRpcRequest();
                IEnumerator <Node> iter    = new XmlRpcParser().ParseRequest(rdr).GetEnumerator();

                iter.MoveNext();
                string methodName = (iter.Current as MethodName).Name;
                request.method = methodName;

                request.mi = null;
                ParameterInfo[] pis = null;
                if (svcType != null)
                {
                    // retrieve info for the method which handles this XML-RPC method
                    XmlRpcServiceInfo svcInfo
                               = XmlRpcServiceInfo.CreateServiceInfo(svcType);
                    request.mi = svcInfo.GetMethodInfo(request.method);
                    // if a service type has been specified and we cannot find the requested
                    // method then we must throw an exception
                    if (request.mi == null)
                    {
                        string msg = String.Format("unsupported method called: {0}",
                                                   request.method);
                        throw new XmlRpcUnsupportedMethodException(msg);
                    }
                    // method must be marked with XmlRpcMethod attribute
                    Attribute attr = Attribute.GetCustomAttribute(request.mi,
                                                                  typeof(XmlRpcMethodAttribute));
                    if (attr == null)
                    {
                        throw new XmlRpcMethodAttributeException(
                                  "Method must be marked with the XmlRpcMethod attribute.");
                    }
                    pis = request.mi.GetParameters();
                }

                bool gotParams = iter.MoveNext();
                if (!gotParams)
                {
                    if (svcType != null)
                    {
                        if (pis.Length == 0)
                        {
                            request.args = new object[0];
                            return(request);
                        }
                        else
                        {
                            throw new XmlRpcInvalidParametersException(
                                      "Method takes parameters and params element is missing.");
                        }
                    }
                    else
                    {
                        request.args = new object[0];
                        return(request);
                    }
                }

                int paramsPos = pis != null?GetParamsPos(pis) : -1;

                Type paramsType = null;
                if (paramsPos != -1)
                {
                    paramsType = pis[paramsPos].ParameterType.GetElementType();
                }
                int minParamCount = pis == null ? int.MaxValue
          : (paramsPos == -1 ? pis.Length : paramsPos);
                MappingStack  mappingStack  = new MappingStack("request");
                MappingAction mappingAction = MappingAction.Error;
                var           objs          = new List <object>();
                var           paramsObjs    = new List <object>();
                int           paramCount    = 0;


                while (iter.MoveNext())
                {
                    paramCount++;
                    if (svcType != null && paramCount > minParamCount && paramsPos == -1)
                    {
                        throw new XmlRpcInvalidParametersException(
                                  "Request contains too many param elements based on method signature.");
                    }
                    if (paramCount <= minParamCount)
                    {
                        if (svcType != null)
                        {
                            mappingStack.Push(String.Format("parameter {0}", paramCount));
                            // TODO: why following commented out?
                            //          parseStack.Push(String.Format("parameter {0} mapped to type {1}",
                            //            i, pis[i].ParameterType.Name));
                            var obj = MapValueNode(iter,
                                                   pis[paramCount - 1].ParameterType, mappingStack, mappingAction);
                            objs.Add(obj);
                        }
                        else
                        {
                            mappingStack.Push(String.Format("parameter {0}", paramCount));
                            var obj = MapValueNode(iter, null, mappingStack, mappingAction);
                            objs.Add(obj);
                        }
                        mappingStack.Pop();
                    }
                    else
                    {
                        mappingStack.Push(String.Format("parameter {0}", paramCount + 1));
                        var paramsObj = MapValueNode(iter, paramsType, mappingStack, mappingAction);
                        paramsObjs.Add(paramsObj);
                        mappingStack.Pop();
                    }
                }

                if (svcType != null && paramCount < minParamCount)
                {
                    throw new XmlRpcInvalidParametersException(
                              "Request contains too few param elements based on method signature.");
                }

                if (paramsPos != -1)
                {
                    Object[] args = new Object[1];
                    args[0] = paramCount - minParamCount;
                    Array varargs = (Array)Activator.CreateInstance(pis[paramsPos].ParameterType, args);
                    for (int i = 0; i < paramsObjs.Count; i++)
                    {
                        varargs.SetValue(paramsObjs[i], i);
                    }
                    objs.Add(varargs);
                }
                request.args = objs.ToArray();
                return(request);
            }
            catch (XmlException ex)
            {
                throw new XmlRpcIllFormedXmlException("Request contains invalid XML", ex);
            }
        }
コード例 #21
0
 public void PropertyMember()
 {
     XmlRpcServiceInfo info = XmlRpcServiceInfo.CreateServiceInfo(typeof(struct3));
 }