• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# XmlRpc.XmlRpcRequestSerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcRequestSerializer的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcRequestSerializer类的具体用法?C# XmlRpcRequestSerializer怎么用?C# XmlRpcRequestSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmlRpcRequestSerializer类属于CookComputing.XmlRpc命名空间,在下文中一共展示了XmlRpcRequestSerializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SerializeObjectParams

    public void SerializeObjectParams()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { new object[] { 1, "one" } };
      req.method = "Foo";
      req.mi = typeof(IFoo).GetMethod("Foo");
      var ser = new XmlRpcRequestSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
    <param>
      <value>
        <string>one</string>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:30,代码来源:paramstest.cs


示例2: SerializeRequestNilParams

        public void SerializeRequestNilParams()
        {
            var stm = new MemoryStream();
            var req = new XmlRpcRequest();
            req.Args = new Object[] { new object[] { 1, null, 2 } };
            req.Method = "NilParamsMethod";
            req.Mi = GetType().GetMethod("NilParamsMethod");
            var ser = new XmlRpcRequestSerializer();
            ser.Indentation = 4;
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            var tr = new StreamReader(stm);
            tr.ReadToEnd().ShouldBe(
@"<?xml version=""1.0""?>
<methodCall>
    <methodName>NilParamsMethod</methodName>
    <params>
        <param>
            <value>
                <i4>1</i4>
            </value>
        </param>
        <param>
            <value>
                <nil />
            </value>
        </param>
        <param>
            <value>
                <i4>2</i4>
            </value>
        </param>
    </params>
</methodCall>");
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:35,代码来源:NilTest.cs


示例3: SerializeRequestNil

    public void SerializeRequestNil()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { null, 1234567 };
      req.method = "NilMethod";
      req.mi = this.GetType().GetMethod("NilMethod");
      var ser = new XmlRpcRequestSerializer();
      ser.Indentation = 4;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
    <methodName>NilMethod</methodName>
    <params>
        <param>
            <value>
                <nil />
            </value>
        </param>
        <param>
            <value>
                <i4>1234567</i4>
            </value>
        </param>
    </params>
</methodCall>", reqstr);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:31,代码来源:NilTest.cs


示例4: Class

        public void Class()
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            TestClass arg = new TestClass();
            arg._int = 456;
            arg._string = "Test Class";
            req.Args = new object[] { arg };
            req.Method = "Foo";
            var ser = new XmlRpcRequestSerializer();
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();

            Assert.AreEqual(@"<?xml version=""1.0""?>
            <methodCall>
              <methodName>Foo</methodName>
              <params>
            <param>
              <value>
            <struct>
              <member>
            <name>_int</name>
            <value>
              <i4>456</i4>
            </value>
              </member>
              <member>
            <name>_string</name>
            <value>
              <string>Test Class</string>
            </value>
              </member>
            </struct>
              </value>
            </param>
              </params>
            </methodCall>", reqstr);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:40,代码来源:serializetest.cs


示例5: SerializeWithMappingOnInterface

    public void SerializeWithMappingOnInterface()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] 
      { 
        IntEnum.Zero,
        new IntEnum[] { IntEnum.One, IntEnum.Two },
        new ItfEnumClass
        { 
          IntEnum = ItfEnum.One, 
          intEnum = ItfEnum.Two,
          IntEnums = new ItfEnum[] { ItfEnum.One, ItfEnum.Two },
          intEnums = new ItfEnum[] { ItfEnum.Three, ItfEnum.Four },
        } 
      };
      req.method = "MappingOnMethod";
      req.mi = this.GetType().GetMethod("MappingOnMethod");
      var ser = new XmlRpcRequestSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>MappingOnMethod</methodName>
  <params>
    <param>
      <value>
        <string>Zero</string>
      </value>
    </param>
    <param>
      <value>
        <array>
          <data>
            <value>
              <string>One</string>
            </value>
            <value>
              <string>Two</string>
            </value>
          </data>
        </array>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>IntEnum</name>
            <value>
              <string>One</string>
            </value>
          </member>
          <member>
            <name>IntEnums</name>
            <value>
              <array>
                <data>
                  <value>
                    <string>One</string>
                  </value>
                  <value>
                    <string>Two</string>
                  </value>
                </data>
              </array>
            </value>
          </member>
          <member>
            <name>intEnum</name>
            <value>
              <string>Two</string>
            </value>
          </member>
          <member>
            <name>intEnums</name>
            <value>
              <array>
                <data>
                  <value>
                    <string>Three</string>
                  </value>
                  <value>
                    <string>Four</string>
                  </value>
                </data>
              </array>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:christianeisendle,项目名称:nunit-testlink-adapter,代码行数:99,代码来源:EnumStringInterfaceMapping.cs


示例6: SerializeRequest

    public void SerializeRequest()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { IntEnum.Two };
      req.method = "Foo";
      var ser = new XmlRpcRequestSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <i4>2</i4>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:25,代码来源:enumtest.cs


示例7: DateTimeLocales

    public void DateTimeLocales()
    {
      CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
      try
      {
        foreach (string locale in Utils.GetLocales())
        {
          try
          {
            CultureInfo ci = new CultureInfo(locale);
            Thread.CurrentThread.CurrentCulture = ci;
            if (ci.LCID == 0x401    // ar-SA  (Arabic - Saudi Arabia)
              || ci.LCID == 0x465   // div-MV (Dhivehi - Maldives)
              || ci.LCID == 0x41e)  // th-TH  (Thai - Thailand)
              break;

            DateTime dt = new DateTime(1900, 01, 02, 03, 04, 05);
            while (dt < DateTime.Now)
            {
              Stream stm = new MemoryStream();
              XmlRpcRequest req = new XmlRpcRequest();
              req.args = new Object[] { dt };
              req.method = "Foo";
              var ser = new XmlRpcRequestSerializer();
              ser.SerializeRequest(stm, req);
              stm.Position = 0;

              var deserializer = new XmlRpcRequestDeserializer();
              XmlRpcRequest request = deserializer.DeserializeRequest(stm, null);

              Assert.IsTrue(request.args[0] is DateTime,
                "argument is DateTime");
              DateTime dt0 = (DateTime)request.args[0];
              Assert.AreEqual(dt0, dt, "DateTime argument 0");
              dt += new TimeSpan(100, 1, 1, 1);
            }
          }
          catch (Exception ex)
          {
              Assert.Fail(String.Format("unexpected exception {0}: {1}",
                locale, ex.Message));
          }
        }
      }
      finally
      {
        Thread.CurrentThread.CurrentCulture = oldci;
      }
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:49,代码来源:deserializerequesttest.cs


示例8: StructParamsWithParams

 public void StructParamsWithParams()
 {
     Stream stm = new MemoryStream();
     XmlRpcRequest req = new XmlRpcRequest();
     req.Args = new object[] { 1234, "test", new[] { 10.1 } };
     req.Method = "FooWithParams";
     req.Mi = this.GetType().GetMethod("FooWithParams");
     var ser = new XmlRpcRequestSerializer();
     ser.Indentation = 2;
     ser.UseIntTag = true;
     ser.SerializeRequest(stm, req);
 }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:12,代码来源:serializetest.cs


示例9: SerializeWithMappingOnType

    public void SerializeWithMappingOnType()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new object[] { IntEnum.Four };
      req.method = "Bar";
      var proxy = XmlRpcProxyGen.Create<TestMethods2>();
      req.mi = proxy.GetType().GetMethod("Bar");
      var ser = new XmlRpcRequestSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>Bar</methodName>
  <params>
    <param>
      <value>
        <string>Four</string>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:26,代码来源:enumtest.cs


示例10: ZeroLengthBas64

        public void ZeroLengthBas64()
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            req.Args = new object[] { new byte[0] };
            req.Method = "Foo";
            var ser = new XmlRpcRequestSerializer();
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();

            Assert.AreEqual(@"<?xml version=""1.0""?>
            <methodCall>
              <methodName>Foo</methodName>
              <params>
            <param>
              <value>
            <base64 />
              </value>
            </param>
              </params>
            </methodCall>", reqstr);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:24,代码来源:serializetest.cs


示例11: SerializeMassimo

 public void SerializeMassimo()
 {
   object[] param1 = new object[] { "test/Gain1", "Gain", 1, 1, 
                                    new double[] { 0.5 } };
   object[] param2 = new object[] { "test/METER", "P1", 1, 1, 
                                    new double[] { -1.0 } };
   Stream stm = new MemoryStream();
   XmlRpcRequest req = new XmlRpcRequest();
   req.args = new Object[] { "IFTASK", 
     new object[] { param1, param2 } };
   req.method = "Send_Param";
   req.mi = this.GetType().GetMethod("Send_Param");
   var ser = new XmlRpcRequestSerializer();
   ser.SerializeRequest(stm, req);
   stm.Position = 0;
   TextReader tr = new StreamReader(stm);
   string reqstr = tr.ReadToEnd();
   Assert.AreEqual(massimoRequest, reqstr);
 }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:19,代码来源:paramstest.cs


示例12: NullMappingNil

 public void NullMappingNil()
 {
     Stream stm = new MemoryStream();
     XmlRpcRequest req = new XmlRpcRequest();
     req.Args = new object[] { new NullMappingNilStruct() };
     req.Method = "Foo";
     var ser = new XmlRpcRequestSerializer();
     ser.SerializeRequest(stm, req);
     stm.Position = 0;
     TextReader tr = new StreamReader(stm);
     string reqstr = tr.ReadToEnd();
     Assert.AreEqual(@"<?xml version=""1.0""?>
     <methodCall>
       <methodName>Foo</methodName>
       <params>
     <param>
       <value>
     <struct>
       <member>
     <name>s</name>
     <value>
       <nil />
     </value>
       </member>
       <member>
     <name>i</name>
     <value>
       <nil />
     </value>
       </member>
     </struct>
       </value>
     </param>
       </params>
     </methodCall>", reqstr);
 }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:36,代码来源:serializetest.cs


示例13: SerializeRequestStructArrayWithNil

    public void SerializeRequestStructArrayWithNil()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { new StructWithArray { ints = new int?[] { 1, null, 3 } } };
      req.method = "NilMethod";
      req.mi = this.GetType().GetMethod("NilMethod");
      var ser = new XmlRpcRequestSerializer();
      ser.Indentation = 4;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
    <methodName>NilMethod</methodName>
    <params>
        <param>
            <value>
                <struct>
                    <member>
                        <name>ints</name>
                        <value>
                            <array>
                                <data>
                                    <value>
                                        <i4>1</i4>
                                    </value>
                                    <value>
                                        <nil />
                                    </value>
                                    <value>
                                        <i4>3</i4>
                                    </value>
                                </data>
                            </array>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodCall>", reqstr);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:45,代码来源:NilTest.cs


示例14: NoIndentation

        public void NoIndentation()
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            req.Args = new object[] { 1234567 };
            req.Method = "Foo";
            var ser = new XmlRpcRequestSerializer();
            ser.UseIndentation = false;
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();

            Assert.AreEqual(
                "<?xml version=\"1.0\"?><methodCall><methodName>Foo</methodName>"
                + "<params><param><value><i4>1234567</i4></value></param></params>" + "</methodCall>",
                reqstr);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:18,代码来源:serializetest.cs


示例15: NoParams2

        public void NoParams2()
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            req.Args = new object[0];
            req.Method = "system.pid";
            req.Mi = this.GetType().GetMethod("getPid");
            var ser = new XmlRpcRequestSerializer();
            ser.Indentation = 2;
            ser.UseIntTag = true;
            ser.UseEmptyParamsTag = false;
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();

            Assert.AreEqual(@"<?xml version=""1.0""?>
            <methodCall>
              <methodName>system.pid</methodName>
            </methodCall>", reqstr);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:21,代码来源:serializetest.cs


示例16: LFString

        public void LFString()
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            req.Args = new object[] { "\n" };
            req.Method = "Foo";
            var ser = new XmlRpcRequestSerializer();
            ser.UseStringTag = true;
            ser.Indentation = 4;
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();

            Assert.AreEqual(@"<?xml version=""1.0""?>
            <methodCall>
            <methodName>Foo</methodName>
            <params>
            <param>
            <value>
                " + "<string>\n</string>" + @"
            </value>
            </param>
            </params>
            </methodCall>", reqstr);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:26,代码来源:serializetest.cs


示例17: DefaultFormatting

        public void DefaultFormatting()
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            req.Args = new object[] { 1234567 };
            req.Method = "Foo";
            var ser = new XmlRpcRequestSerializer();
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();

            Assert.AreEqual(@"<?xml version=""1.0""?>
            <methodCall>
              <methodName>Foo</methodName>
              <params>
            <param>
              <value>
            <i4>1234567</i4>
              </value>
            </param>
              </params>
            </methodCall>", reqstr);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:24,代码来源:serializetest.cs


示例18: NonSerializedWithInvalidType

 public void NonSerializedWithInvalidType()
 {
     Stream stm = new MemoryStream();
     XmlRpcRequest req = new XmlRpcRequest();
     req.Args = new object[] { new Struct5 { ds = new System.Data.DataSet(), y = 1234 } };
     req.Method = "Foo";
     var ser = new XmlRpcRequestSerializer();
     ser.SerializeRequest(stm, req);
     stm.Position = 0;
     TextReader tr = new StreamReader(stm);
     string reqstr = tr.ReadToEnd();
     Assert.AreEqual(@"<?xml version=""1.0""?>
     <methodCall>
       <methodName>Foo</methodName>
       <params>
     <param>
       <value>
     <struct>
       <member>
     <name>y</name>
     <value>
       <i4>1234</i4>
     </value>
       </member>
     </struct>
       </value>
     </param>
       </params>
     </methodCall>", reqstr);
 }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:30,代码来源:serializetest.cs


示例19: SerializeMessage

        //  private methods
        //
        void SerializeMessage(
          IMethodCallMessage mcm,
          ref ITransportHeaders headers,
          ref Stream stream)
        {
            ITransportHeaders reqHeaders = new TransportHeaders();
            reqHeaders["__Uri"] = mcm.Uri;
            reqHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";
            reqHeaders["__RequestVerb"] = "POST";

            MethodInfo mi = (MethodInfo)mcm.MethodBase;
            string methodName = GetRpcMethodName(mi);
            XmlRpcRequest xmlRpcReq = new XmlRpcRequest(methodName, mcm.InArgs);
            // TODO: possibly call GetRequestStream from next sink in chain?
            // TODO: SoapClientFormatter sink uses ChunkedStream - check why?
            Stream stm = new MemoryStream();
            var serializer = new XmlRpcRequestSerializer();
            serializer.SerializeRequest(stm, xmlRpcReq);
            stm.Position = 0;

            headers = reqHeaders;
            stream = stm;
        }
开发者ID:Orvid,项目名称:Zutubi.Pulse.Api,代码行数:25,代码来源:XmlRpcClientFormatterSink.cs


示例20: SerializeIntNoParams

    public void SerializeIntNoParams()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new object[] { new int[] { 1, 2, 3 } };
      req.method = "BarNotParams";
      req.mi = typeof(IFoo).GetMethod("BarNotParams");
      var ser = new XmlRpcRequestSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>BarNotParams</methodName>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <i4>1</i4>
            </value>
            <value>
              <i4>2</i4>
            </value>
            <value>
              <i4>3</i4>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:37,代码来源:paramstest.cs



注:本文中的CookComputing.XmlRpc.XmlRpcRequestSerializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# XmlRpc.XmlRpcResponseDeserializer类代码示例发布时间:2022-05-24
下一篇:
C# XmlRpc.XmlRpcRequestDeserializer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap