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

C# XmlRpc.XmlRpcResponseDeserializer类代码示例

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

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



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

示例1: AdvogatoProblem

        public void AdvogatoProblem()
        {
            const string Xml =
            @"<?xml version='1.0'?>
            <methodResponse>
            <params>
            <param>
            <array>
            <data>
            <value>
            <dateTime.iso8601>20020707T11:25:37</dateTime.iso8601>
            </value>
            <value>
            <dateTime.iso8601>20020707T11:37:12</dateTime.iso8601>
            </value>
            </data>
            </array>
            </param>
            </params>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            try
            {
                var response = deserializer.DeserializeResponse(sr, null);
                var o = response.RetVal;
                Assert.Fail("should have thrown XmlRpcInvalidXmlRpcException");
            }
            catch (XmlRpcInvalidXmlRpcException)
            {
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:33,代码来源:DeserializeResponseTests.cs


示例2: AllowInvalidHTTPContentLeadingWhiteSpace

        public void AllowInvalidHTTPContentLeadingWhiteSpace()
        {
            const string Xml =
            @"

            <?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><i4>12345</i4></value>
            </param>
              </params>
            </methodResponse>";

            Stream stm = new MemoryStream();
            var wrtr = new StreamWriter(stm, Encoding.ASCII);
            wrtr.Write(Xml);
            wrtr.Flush();
            stm.Position = 0;
            var deserializer = new XmlRpcResponseDeserializer();
            deserializer.NonStandard = XmlRpcNonStandard.AllowInvalidHTTPContent;
            var response = deserializer.DeserializeResponse(stm, typeof(int));

            var o = response.RetVal;
            Assert.IsTrue(o != null, "retval not null");
            Assert.IsTrue(o is int, "retval is int");
            Assert.AreEqual((int)o, 12345, "retval is 12345");
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:28,代码来源:DeserializeResponseTests.cs


示例3: DeserializeResponseStructWithNil

    public void DeserializeResponseStructWithNil()
    {
      string xml = @"<?xml version=""1.0"" ?> 
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>lowerBound</name>
            <value><nil/></value>
          </member>
          <member>
            <name>upperBound</name>
            <value><nil/></value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodResponse>";
      StringReader sr = new StringReader(xml);
      var deserializer = new XmlRpcResponseDeserializer();
      XmlRpcResponse response = deserializer.DeserializeResponse(sr, typeof(ServerBounds));
      Assert.IsInstanceOf<ServerBounds>(response.retVal);
      ServerBounds bounds = response.retVal as ServerBounds;
      Assert.IsNull(bounds.lowerBound);
      Assert.IsNull(bounds.upperBound);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:29,代码来源:NilTestServer.cs


示例4: DeserializeResponseNilMethod

    public void DeserializeResponseNilMethod()
    {
      string xml = @"<?xml version=""1.0"" ?> 
<methodResponse>
  <params>
    <param>
      <value><nil /></value>
    </param>
  </params>
</methodCall>";
      StringReader sr = new StringReader(xml);
      var deserializer = new XmlRpcResponseDeserializer();
      XmlRpcResponse response = deserializer.DeserializeResponse(sr, this.GetType());

      Assert.IsNull(response.retVal, "return value is null");
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:16,代码来源:NilTestServer.cs


示例5: IntegerNullType

    public void IntegerNullType()
    {
      string xml = @"<?xml version=""1.0"" ?> 
<methodResponse>
  <params>
    <param>
      <value><int>12345</int></value>
    </param>
  </params>
</methodResponse>";
      StringReader sr = new StringReader(xml);
      var deserializer = new XmlRpcResponseDeserializer();
      XmlRpcResponse response = deserializer.DeserializeResponse(sr, null);

      Object o = response.retVal;
      Assert.IsTrue(o != null, "retval not null");
      Assert.IsTrue(o is int, "retval is int");
      Assert.AreEqual((int)o, 12345, "retval is 12345");
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:19,代码来源:deserializeresponsetest.cs


示例6: MissingStructMember

        public void MissingStructMember()
        {
            const string Xml =
            @"<?xml version='1.0'?>
            <methodResponse>
              <params>
            <param>
              <value>
            <struct>
              <member>
            <name>x</name>
            <value>
              <i4>123</i4>
            </value>
              </member>
            </struct>
              </value>
            </param>
              </params>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            try
            {
                deserializer.DeserializeResponse(sr, typeof(BillStruct));
                Assert.Fail("Should detect missing struct member");
            }
            catch (AssertionException)
            {
                throw;
            }
            catch (Exception)
            {
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:36,代码来源:DeserializeResponseTests.cs


示例7: OneByteContentAllowInvalidHTTPContent

 public void OneByteContentAllowInvalidHTTPContent()
 {
     const string Xml = @"<";
     Stream stm = new MemoryStream();
     var wrtr = new StreamWriter(stm, Encoding.ASCII);
     wrtr.Write(Xml);
     wrtr.Flush();
     stm.Position = 0;
     var deserializer = new XmlRpcResponseDeserializer();
     deserializer.NonStandard = XmlRpcNonStandard.AllowInvalidHTTPContent;
     deserializer.DeserializeResponse(stm, typeof(int));
 }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:12,代码来源:DeserializeResponseTests.cs


示例8: MinDateTime4NotStrict

        public void MinDateTime4NotStrict()
        {
            const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><dateTime.iso8601>0000-00-00T00:00:00Z</dateTime.iso8601></value>
            </param>
              </params>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            deserializer.NonStandard = XmlRpcNonStandard.MapZerosDateTimeToMinValue;
            var response = deserializer.DeserializeResponse(sr, typeof(DateTime));

            var o = response.RetVal;
            Assert.IsTrue(o is DateTime, "retval is string");
            Assert.AreEqual((DateTime)o, DateTime.MinValue, "DateTime.MinValue");
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:21,代码来源:DeserializeResponseTests.cs


示例9: MinDateTimeStrict

        public void MinDateTimeStrict()
        {
            const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><dateTime.iso8601>00000000T00:00:00</dateTime.iso8601></value>
            </param>
              </params>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer
            {
                NonStandard = XmlRpcNonStandard.AllowNonStandardDateTime
            };
            try
            {
                deserializer.DeserializeResponse(sr, typeof(DateTime));
                Assert.Fail("dateTime 00000000T00:00:00 invalid when strict");
            }
            catch (XmlRpcInvalidXmlRpcException)
            {
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:26,代码来源:DeserializeResponseTests.cs


示例10: FaultResponse

        public void FaultResponse()
        {
            const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <fault>
            <value>
              <struct>
            <member>
              <name>FaultCode</name>
              <value><int>4</int></value>
            </member>
            <member>
              <name>FaultString</name>
              <value><string>Too many parameters.</string></value>
            </member>
              </struct>
            </value>
              </fault>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            try
            {
                deserializer.DeserializeResponse(sr, typeof(void));
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(fex.FaultCode, 4);
                Assert.AreEqual(fex.FaultString, "Too many parameters.");
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:33,代码来源:DeserializeResponseTests.cs


示例11: Donhrobjartz_XmlRpcStructNonMemberStructChild

        public void Donhrobjartz_XmlRpcStructNonMemberStructChild()
        {
            const string Xml =
            @"<?xml version=""1.0"" encoding=""iso-8859-1""?>
            <methodResponse>
            <params>
            <param>
            <value>
            <struct>
            <foo>
            This should be ignored.
            </foo>
            <member>
            <name>period</name>
            <value><string>1w</string></value>
            </member>
            <bar>
            This should be ignored.
            </bar>
            </struct>
            </value>
            </param>
            </params>
            </methodResponse>";

            var sr1 = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            deserializer.NonStandard = XmlRpcNonStandard.IgnoreDuplicateMembers;
            var response = deserializer.DeserializeResponse(sr1, typeof(XmlRpcStruct));
            var ret = (XmlRpcStruct)response.RetVal;
            Assert.AreEqual(ret.Count, 1);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:32,代码来源:DeserializeResponseTests.cs


示例12: Deserialize

    public void Deserialize()
    {
      string xml =
@"<?xml version=""1.0"" encoding=""iso-8859-1""?>
<methodResponse>
  <params>
    <param>
      <value>
        <i4>2</i4>
      </value>
    </param>
  </params>
</methodResponse>";
      StringReader sr1 = new StringReader(xml);
      var deserializer = new XmlRpcResponseDeserializer();
      XmlRpcResponse response = deserializer.DeserializeResponse(sr1,
        typeof(IntEnum));
      IntEnum ret = (IntEnum)response.retVal;
      Assert.AreEqual(IntEnum.Two, ret);
    }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:20,代码来源:enumtest.cs


示例13: Donhrobjartz_XmlRpcStructMemberDupValue

        public void Donhrobjartz_XmlRpcStructMemberDupValue()
        {
            const string Xml =
            @"<?xml version=""1.0"" encoding=""iso-8859-1""?>
            <methodResponse>
            <params>
            <param>
            <value>
            <struct>
            <member>
            <name>period</name>
            <value><string>1w</string></value>
            <value><string>284</string></value>
            </member>
            </struct>
            </value>
            </param>
            </params>
            </methodResponse>";

            var sr1 = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            deserializer.NonStandard = XmlRpcNonStandard.IgnoreDuplicateMembers;
            var response = deserializer.DeserializeResponse(sr1, typeof(XmlRpcStruct));
            var ret = (XmlRpcStruct)response.RetVal;
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:26,代码来源:DeserializeResponseTests.cs


示例14: IntegerIncorrectType

        public void IntegerIncorrectType()
        {
            try
            {
                const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><int>12345</int></value>
            </param>
              </params>
            </methodResponse>";

                var sr = new StringReader(Xml);
                var deserializer = new XmlRpcResponseDeserializer();
                deserializer.DeserializeResponse(sr, typeof(string));
                Assert.Fail("Should throw XmlRpcTypeMismatchException");
            }
            catch (XmlRpcTypeMismatchException)
            {
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:23,代码来源:DeserializeResponseTests.cs


示例15: IntegerWithType

        public void IntegerWithType()
        {
            const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><int>12345</int></value>
            </param>
              </params>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            var response = deserializer.DeserializeResponse(sr, typeof(int));

            var o = response.RetVal;
            Assert.IsTrue(o != null, "retval not null");
            Assert.IsTrue(o is int, "retval is int");
            Assert.AreEqual((int)o, 12345, "retval is 12345");
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:21,代码来源:DeserializeResponseTests.cs


示例16: Gabe

        public void Gabe()
        {
            const string Xml =
            @"<?xml version=""1.0"" encoding=""UTF-8""?><methodResponse><params><param><value><struct><member><name>response</name><value><struct><member><name>result</name><value><array><data><value><struct><member><name>state</name><value><string>CO</string></value></member><member><name>latitude</name><value><double>39.74147878</double></value></member><member><name>add1</name><value><string>110 16th St.</string></value></member><member><name>add2</name><value><string /></value></member><member><name>image_map</name><value><array><data><value><string>rect</string></value><value><int>290</int></value><value><int>190</int></value><value><int>309</int></value><value><int>209</int></value></data></array></value></member><member><name>city</name><value><string>Denver</string></value></member><member><name>fax</name><value><string>303-623-1111</string></value></member><member><name>name</name><value><boolean>0"
            + "</boolean></value></member><member><name>longitude</name><value><double>-104.9874159</double></value></member><member><name>georesult</name><value><string>10 W2GIADDRESS</string></value></member><member><name>zip</name><value><string>80202</string></value></member><member><name>hours</name><value><string>Mon-Sun 10am-6pm</string></value></member><member><name>dealerid</name><value><string>545</string></value></member><member><name>phone</name><value><string>303-623-5050</string></value></member></struct></value></data></array></value></member><member><name>map_id</name><value><string>a5955239d080dfbb7002fd063aa7b47e0d</string></value></member><member><name>map</name><value><struct><member><name>zoom_level</name><value><int>3</int></value></member><member><name>image_type</name><value><string>image/png</string></value></member><member><name>miles</name><value><double>1.75181004463519</double></value></member><member><name>kilometers</name><value><double>2.81926498447338"
            + "</double></value></member><member><name>scalebar</name><value><int>1</int></value></member><member><name>content</name><value><string>http://mapserv.where2getit.net/maptools/mapserv.cgi/a5955239d080dfbb7002fd063aa7b47e0d.png</string></value></member><member><name>scale</name><value><int>26000</int></value></member><member><name>map_style</name><value><string>default</string></value></member><member><name>size</name><value><array><data><value><int>600</int></value><value><int>400</int></value></data></array></value></member><member><name>content_type</name><value><string>text/uri-list</string></value></member><member><name>buffer</name><value><double>0.01</double></value></member><member><name>center</name><value><struct><member><name>georesult</name><value><string>AUTOBBOX</string></value></member><member><name>latitude</name><value><double>39.74147878</double></value></member><member><name>longitude</name><value><double>-104.9874159</double></value></member></struct></value></member></struct></value></member><member><name>result_count</name><value><int>1</int></value></member><member><name>image_map</name><value><boolean>1</boolean></value></member><member><name>result_total_count</name><value><int>1</int></value></member></struct></value></member><member><name>times</name><value><struct><member><name>csys</name><value><int>0</int></value></member><member><name>cusr</name><value><int>0</int></value></member><member><name>sys</name><value><int>0</int></value></member><member><name>usr</name><value><double>0.0200000000000005"
            + "</double></value></member><member><name>wallclock</name><value><double>2.547471</double></value></member></struct></value></member><member><name>request</name><value><struct><member><name>state</name><value><string>CO</string></value></member><member><name>%sort</name><value><array><data /></array></value></member><member><name>%id</name><value><string>4669b341d87be7f450b4bf0dc4cd0a1e</string></value></member><member><name>city</name><value><string>denver</string></value></member><member><name>%limit</name><value><int>10</int></value></member><member><name>%offset</name><value><int>0</int></value></member></struct></value></member></struct></value></param></params></methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            var response = deserializer.DeserializeResponse(sr, typeof(XmlRpcStruct));

            var response_struct = (XmlRpcStruct)response.RetVal;
            var _response = (XmlRpcStruct)response_struct["response"];
            var results = (Array)_response["result"];
            Assert.AreEqual(results.Length, 1);
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:17,代码来源:DeserializeResponseTests.cs


示例17: EmptyParamsVoidReturn

 public void EmptyParamsVoidReturn()
 {
     const string Xml =
     @"<?xml version=""1.0""?>
     <methodResponse>
       <params/>
     </methodResponse>
     ";
     var sr1 = new StringReader(Xml);
     var deserializer = new XmlRpcResponseDeserializer();
     var response = deserializer.DeserializeResponse(sr1, typeof(void));
     Assert.IsNull(response.RetVal);
 }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:13,代码来源:DeserializeResponseTests.cs


示例18: FaultStringCodeWithAllowStringFaultCode

        public void FaultStringCodeWithAllowStringFaultCode()
        {
            // Alex Hung reported that some servers, e.g. WordPress, return fault code
            // as a string
            const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <fault>
            <value>
              <struct>
            <member>
              <name>FaultCode</name>
              <value><string>4</string></value>
            </member>
            <member>
              <name>FaultString</name>
              <value><string>Too many parameters.</string></value>
            </member>
              </struct>
            </value>
              </fault>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer { NonStandard = XmlRpcNonStandard.AllowStringFaultCode };
            try
            {
                deserializer.DeserializeResponse(sr, typeof(void));
                Assert.Fail("Expected fault exception to be thrown");
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(fex.FaultCode, 4);
                Assert.AreEqual(fex.FaultString, "Too many parameters.");
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:36,代码来源:DeserializeResponseTests.cs


示例19: ReturnNestedStruct

        public void ReturnNestedStruct()
        {
            const string Xml =
            @"<?xml version=""1.0"" encoding=""ISO-8859-1""?>
            <methodResponse>
              <params>
            <param>
              <value>
            <struct>
              <member>
            <name>Version</name>
            <value><string>1.6</string></value>
              </member>
              <member>
            <name>Record</name>
            <value>
              <struct>
                <member>
                  <name>FirstName</name>
                  <value>Joe</value></member>
                <member>
                  <name>LastName</name>
                  <value>Test</value>
                </member>
              </struct>
            </value>
              </member>
            </struct>
              </value>
            </param>
              </params>
            </methodResponse>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            var response = deserializer.DeserializeResponse(sr, typeof(MyStruct));

            var o = response.RetVal;
            Assert.IsTrue(o is MyStruct, "retval is MyStruct");
            var mystr = (MyStruct)o;
            Assert.AreEqual(mystr.Version, "1.6", "version is 1.6");
            Assert.IsTrue(mystr.Record.FirstName == "Joe", "firstname is Joe");
            Assert.IsTrue(mystr.Record.LastName == "Test", "lastname is Test");
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:44,代码来源:DeserializeResponseTests.cs


示例20: DeserializeResponseNilMethod

        public void DeserializeResponseNilMethod()
        {
            const string Xml =
            @"<?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><nil /></value>
            </param>
              </params>
            </methodCall>";

            var sr = new StringReader(Xml);
            var deserializer = new XmlRpcResponseDeserializer();
            var response = deserializer.DeserializeResponse(sr, GetType());

            response.RetVal.ShouldBeNull();
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:18,代码来源:NilTestServer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# XmlRpc.XmlRpcSerializer类代码示例发布时间:2022-05-24
下一篇:
C# XmlRpc.XmlRpcRequestSerializer类代码示例发布时间: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