本文整理汇总了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)
{
}
}
示例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");
}
示例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);
}
示例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");
}
示例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");
}
示例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)
{
}
}
示例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));
}
示例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");
}
示例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)
{
}
}
示例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.");
}
}
示例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);
}
示例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);
}
示例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;
}
示例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)
{
}
}
示例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");
}