当前位置: 首页>>代码示例>>C#>>正文


C# XmlRpc.XmlRpcResponseDeserializer类代码示例

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


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


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