本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcRequestSerializer类的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcRequestSerializer类的具体用法?C# XmlRpcRequestSerializer怎么用?C# XmlRpcRequestSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlRpcRequestSerializer类属于CookComputing.XmlRpc命名空间,在下文中一共展示了XmlRpcRequestSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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>");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}