本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcRequestDeserializer类的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcRequestDeserializer类的具体用法?C# XmlRpcRequestDeserializer怎么用?C# XmlRpcRequestDeserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlRpcRequestDeserializer类属于CookComputing.XmlRpc命名空间,在下文中一共展示了XmlRpcRequestDeserializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Base64MultiLine
public void Base64MultiLine()
{
string xml = @"<?xml version=""1.0""?>
<methodCall>
<methodName>TestHex</methodName>
<params>
<param>
<value>
<base64>AQIDBAUGBwgJ
AQIDBAUGBwg=</base64>
</value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.AreEqual(request.Args[0].GetType(), typeof(byte[]),
"argument is byte[]");
byte[] ret = (byte[])request.Args[0];
Assert.AreEqual(17, ret.Length, "argument is byte[17]");
for (int i = 0; i < 9; i++)
Assert.AreEqual(i + 1, ret[i], "first 9 members are 1 to 9");
for (int i = 0; i < 8; i++)
Assert.AreEqual(i + 1, ret[i + 9], "last 8 members are 1 to 9");
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:27,代码来源:DeserializeRequestTests.cs
示例2: Invoke
public Stream Invoke(Stream requestStream)
{
try
{
var serializer = new XmlRpcResponseSerializer();
var deserializer = new XmlRpcRequestDeserializer();
Type type = this.GetType();
XmlRpcServiceAttribute serviceAttr = (XmlRpcServiceAttribute)
Attribute.GetCustomAttribute(this.GetType(),
typeof(XmlRpcServiceAttribute));
if (serviceAttr != null)
{
if (serviceAttr.XmlEncoding != null)
{
serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding) ?? Config.DefaultEncoding;
}
serializer.UseEmptyParamsTag = serviceAttr.UseEmptyElementTags;
serializer.UseIntTag = serviceAttr.UseIntTag;
serializer.UseStringTag = serviceAttr.UseStringTag;
serializer.UseIndentation = serviceAttr.UseIndentation;
serializer.Indentation = serviceAttr.Indentation;
}
XmlRpcRequest xmlRpcReq = deserializer.DeserializeRequest(requestStream, this.GetType());
XmlRpcResponse xmlRpcResp = Invoke(xmlRpcReq);
Stream responseStream = new MemoryStream();
serializer.SerializeResponse(responseStream, xmlRpcResp);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
catch (Exception ex)
{
XmlRpcFaultException fex;
if (ex is XmlRpcException)
fex = new XmlRpcFaultException(0, ((XmlRpcException)ex).Message);
else if (ex is XmlRpcFaultException)
fex = (XmlRpcFaultException)ex;
else
fex = new XmlRpcFaultException(0, ex.Message);
XmlRpcSerializer serializer = new XmlRpcSerializer();
Stream responseStream = new MemoryStream();
serializer.SerializeFaultResponse(responseStream, fex);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
}
开发者ID:AntonWong,项目名称:cms,代码行数:48,代码来源:XmlRpcServerProtocol.cs
示例3: DeserializeRequestStructWithNil
public void DeserializeRequestStructWithNil()
{
const string Xml =
@"<?xml version=""1.0""?>
<methodCall>
<methodName>StructWithArrayMethod</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>";
var sr = new StringReader(Xml);
var deserializer = new XmlRpcRequestDeserializer();
var request = deserializer.DeserializeRequest(sr, GetType());
request.Method.ShouldBe("StructWithArrayMethod");
request.Args.Length.ShouldBe(1);
request.Args[0].ShouldBeOfType<StructWithArray>();
((StructWithArray)request.Args[0]).ints
.ShouldBe(new int?[] { 1, null, 3});
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:44,代码来源:NilTestServer.cs
示例4: Invoke
public Stream Invoke(Stream requestStream)
{
try
{
var serializer = new XmlRpcResponseSerializer();
var deserializer = new XmlRpcRequestDeserializer();
var serviceAttr = Attribute.GetCustomAttribute(GetType(), typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;
if (serviceAttr != null)
{
if (serviceAttr.XmlEncoding != null)
serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding);
serializer.UseEmptyParamsTag = serviceAttr.UseEmptyElementTags;
serializer.UseIntTag = serviceAttr.UseIntTag;
serializer.UseStringTag = serviceAttr.UseStringTag;
serializer.UseIndentation = serviceAttr.UseIndentation;
serializer.Indentation = serviceAttr.Indentation;
}
var xmlRpcReq = deserializer.DeserializeRequest(requestStream, GetType());
var xmlRpcResp = Invoke(xmlRpcReq);
var responseStream = new MemoryStream();
serializer.SerializeResponse(responseStream, xmlRpcResp);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
catch (Exception ex)
{
XmlRpcFaultException fex;
var xmlRpcException = ex as XmlRpcException;
if (xmlRpcException != null)
fex = new XmlRpcFaultException(0, xmlRpcException.Message);
else
{
fex = (ex as XmlRpcFaultException)
?? new XmlRpcFaultException(0, ex.Message);
}
var serializer = new XmlRpcSerializer();
var responseStream = new MemoryStream();
serializer.SerializeFaultResponse(responseStream, fex);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:44,代码来源:XmlRpcServerProtocol.cs
示例5: StringEmptyValue1
public void StringEmptyValue1()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestString</methodName>
<params>
<param>
<value></value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.AreEqual(request.method, "TestString", "method is TestString");
Assert.AreEqual(request.args[0].GetType(), typeof(string),
"argument is string");
Assert.AreEqual((string)request.args[0], "", "argument is empty string");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:20,代码来源:deserializerequesttest.cs
示例6: Base64Empty
public void Base64Empty()
{
const string Xml =
@"<?xml version=""1.0""?>
<methodCall>
<methodName>TestHex</methodName>
<params>
<param>
<value>
<base64></base64>
</value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(Xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.AreEqual(request.Args[0].GetType(), typeof(byte[]),
"argument is byte[]");
Assert.AreEqual(request.Args[0], new byte[0],
"argument is zero length byte[]");
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:23,代码来源:DeserializeRequestTests.cs
示例7: DeserializeRequestNilMethod
public void DeserializeRequestNilMethod()
{
const string Xml =
@"<?xml version=""1.0"" ?>
<methodCall>
<methodName>NilMethod</methodName>
<params>
<param>
<value><nil /></value>
</param>
<param>
<value><int>12345</int></value>
</param>
</params>
</methodCall>";
var sr = new StringReader(Xml);
var deserializer = new XmlRpcRequestDeserializer();
var request = deserializer.DeserializeRequest(sr, GetType());
request.Method.ShouldBe("NilMethod");
request.Args[0].ShouldBeNull();
request.Args[1].ShouldBe(12345);
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:24,代码来源:NilTestServer.cs
示例8: 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
示例9: DateTimeFormats
public void DateTimeFormats()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestDateTime</methodName>
<params>
<param>
<value><dateTime.iso8601>20020707T11:25:37Z</dateTime.iso8601></value>
</param>
<param>
<value><dateTime.iso8601>20020707T11:25:37</dateTime.iso8601></value>
</param>
<param>
<value><dateTime.iso8601>2002-07-07T11:25:37Z</dateTime.iso8601></value>
</param>
<param>
<value><dateTime.iso8601>2002-07-07T11:25:37</dateTime.iso8601></value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
deserializer.NonStandard = XmlRpcNonStandard.AllowNonStandardDateTime;
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.IsTrue(request.args[0] is DateTime, "argument is DateTime");
DateTime dt0 = (DateTime)request.args[0];
DateTime dt1 = (DateTime)request.args[1];
DateTime dt2 = (DateTime)request.args[2];
DateTime dt3 = (DateTime)request.args[3];
DateTime dt = new DateTime(2002, 7, 7, 11, 25, 37);
Assert.AreEqual(dt0, dt, "DateTime WordPress");
Assert.AreEqual(dt0, dt, "DateTime XML-RPC spec");
Assert.AreEqual(dt0, dt, "DateTime TypePad");
Assert.AreEqual(dt0, dt, "DateTime other");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:38,代码来源:deserializerequesttest.cs
示例10: StructProperties
public void StructProperties()
{
string xml = @"<?xml version=""1.0""?>
<methodCall>
<methodName>Foo</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>member1</name>
<value>
<i4>1</i4>
</value>
</member>
<member>
<name>member2</name>
<value>
<i4>2</i4>
</value>
</member>
<member>
<name>member-3</name>
<value>
<i4>3</i4>
</value>
</member>
<member>
<name>member-4</name>
<value>
<i4>4</i4>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.AreEqual(request.args[0].GetType(), typeof(XmlRpcStruct),
"argument is XmlRpcStruct");
XmlRpcStruct xrs = (XmlRpcStruct)request.args[0];
Assert.IsTrue(xrs.Count == 4, "XmlRpcStruct has 4 members");
Assert.IsTrue(xrs.ContainsKey("member1") && (int)xrs["member1"] == 1,
"member1");
Assert.IsTrue(xrs.ContainsKey("member2") && (int)xrs["member2"] == 2,
"member2");
Assert.IsTrue(xrs.ContainsKey("member-3") && (int)xrs["member-3"] == 3,
"member-3");
Assert.IsTrue(xrs.ContainsKey("member-4") && (int)xrs["member-4"] == 4,
"member-4");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:59,代码来源:deserializerequesttest.cs
示例11: MissingParams
public void MissingParams()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestString</methodName>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:10,代码来源:deserializerequesttest.cs
示例12: DeserializeObjectParamsStrings
public void DeserializeObjectParamsStrings()
{
string xml =
@"<?xml version=""1.0""?>
<methodCall>
<methodName>Bar</methodName>
<params>
<param>
<value>
<string>one</string>
</value>
</param>
<param>
<value>
<string>two</string>
</value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, this.GetType());
Assert.AreEqual(request.method, "Bar", "method is Foo");
Assert.AreEqual(request.args[0].GetType(), typeof(string[]),
"argument is string[]");
Assert.AreEqual((string[])request.args[0], new string[] { "one", "two" },
"argument is params array \"one\", \"two\"");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:28,代码来源:paramstest.cs
示例13: DeserializeZeroParameters
public void DeserializeZeroParameters()
{
string xml =
@"<?xml version=""1.0""?>
<methodCall>
<methodName>FooZeroParameters</methodName>
<params />
</methodCall>";
StringReader sr = new StringReader(xml);
var serializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = serializer.DeserializeRequest(sr,
this.GetType());
Assert.AreEqual(request.method, "FooZeroParameters",
"method is FooZeroParameters");
Assert.AreEqual(0, request.args.Length, "no arguments");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:16,代码来源:paramstest.cs
示例14: ZeroI8
public void ZeroI8()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestInt</methodName>
<params>
<param>
<value><i8>0</i8></value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.AreEqual(request.args[0].GetType(), typeof(long),
"argument is long");
Assert.AreEqual((long)request.args[0], 0, "argument is 0");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:18,代码来源:deserializerequesttest.cs
示例15: ZeroInteger
public void ZeroInteger()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestInt</methodName>
<params>
<param>
<value><i4>0</i4></value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.IsTrue(request.method == "TestInt", "method is TestInt");
Assert.AreEqual(request.args[0].GetType(), typeof(int),
"argument is int");
Assert.AreEqual((int)request.args[0], 0, "argument is 0");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:20,代码来源:deserializerequesttest.cs
示例16: InvalidInteger
public void InvalidInteger()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestInt</methodName>
<params>
<param>
<value><i4>12kiol</i4></value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
Assert.Fail("Invalid integer should cause exception");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:16,代码来源:deserializerequesttest.cs
示例17: EmptyInteger
public void EmptyInteger()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>TestInt</methodName>
<params>
<param>
<value><i4></i4></value>
</param>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var serializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:15,代码来源:deserializerequesttest.cs
示例18: NoParam2
public void NoParam2()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>MethodNoArgs</methodName>
<params>
</params>
</methodCall>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, this.GetType());
//Console.WriteLine("");
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:13,代码来源:deserializerequesttest.cs
示例19: NoParam1
public void NoParam1()
{
string xml = @"<?xml version=""1.0"" ?>
<methodCall>
<methodName>MethodNoArgs</methodName>
<params/>
</methodCall>";
StringReader sr = new StringReader(xml);
var serializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:11,代码来源:deserializerequesttest.cs
示例20: MissingMethodCall
public void MissingMethodCall()
{
string xml = @"<?xml version=""1.0"" ?> <elem/>";
StringReader sr = new StringReader(xml);
var deserializer = new XmlRpcRequestDeserializer();
XmlRpcRequest request = deserializer.DeserializeRequest(sr, null);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:7,代码来源:deserializerequesttest.cs
注:本文中的CookComputing.XmlRpc.XmlRpcRequestDeserializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论