diff options
Diffstat (limited to 'Common/XmlRpcCS/XmlRpcRequestSerializer.cs')
-rw-r--r-- | Common/XmlRpcCS/XmlRpcRequestSerializer.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Common/XmlRpcCS/XmlRpcRequestSerializer.cs b/Common/XmlRpcCS/XmlRpcRequestSerializer.cs new file mode 100644 index 0000000..8099bdb --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcRequestSerializer.cs | |||
@@ -0,0 +1,51 @@ | |||
1 | namespace Nwc.XmlRpc | ||
2 | { | ||
3 | using System; | ||
4 | using System.Collections; | ||
5 | using System.Xml; | ||
6 | using System.IO; | ||
7 | |||
8 | /// <summary>Class responsible for serializing an XML-RPC request.</summary> | ||
9 | /// <remarks>This class handles the request envelope, depending on <c>XmlRpcSerializer</c> | ||
10 | /// to serialize the payload.</remarks> | ||
11 | /// <seealso cref="XmlRpcSerializer"/> | ||
12 | public class XmlRpcRequestSerializer : XmlRpcSerializer | ||
13 | { | ||
14 | static private XmlRpcRequestSerializer _singleton; | ||
15 | /// <summary>A static singleton instance of this deserializer.</summary> | ||
16 | static public XmlRpcRequestSerializer Singleton | ||
17 | { | ||
18 | get | ||
19 | { | ||
20 | if (_singleton == null) | ||
21 | _singleton = new XmlRpcRequestSerializer(); | ||
22 | |||
23 | return _singleton; | ||
24 | } | ||
25 | } | ||
26 | |||
27 | /// <summary>Serialize the <c>XmlRpcRequest</c> to the output stream.</summary> | ||
28 | /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param> | ||
29 | /// <param name="obj">An <c>XmlRpcRequest</c> to serialize.</param> | ||
30 | /// <seealso cref="XmlRpcRequest"/> | ||
31 | override public void Serialize(XmlTextWriter output, Object obj) | ||
32 | { | ||
33 | XmlRpcRequest request = (XmlRpcRequest)obj; | ||
34 | output.WriteStartDocument(); | ||
35 | output.WriteStartElement(METHOD_CALL); | ||
36 | output.WriteElementString(METHOD_NAME, request.MethodName); | ||
37 | output.WriteStartElement(PARAMS); | ||
38 | foreach (Object param in request.Params) | ||
39 | { | ||
40 | output.WriteStartElement(PARAM); | ||
41 | output.WriteStartElement(VALUE); | ||
42 | SerializeObject(output, param); | ||
43 | output.WriteEndElement(); | ||
44 | output.WriteEndElement(); | ||
45 | } | ||
46 | |||
47 | output.WriteEndElement(); | ||
48 | output.WriteEndElement(); | ||
49 | } | ||
50 | } | ||
51 | } | ||