diff options
updated to use lastest version of libsl but is currently broke when using SL viewer 1.15.02, due to big changes in the message templates.
Diffstat (limited to '')
-rw-r--r-- | XmlRpcCS/XmlRpcResponseSerializer.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/XmlRpcCS/XmlRpcResponseSerializer.cs b/XmlRpcCS/XmlRpcResponseSerializer.cs new file mode 100644 index 0000000..72ca568 --- /dev/null +++ b/XmlRpcCS/XmlRpcResponseSerializer.cs | |||
@@ -0,0 +1,57 @@ | |||
1 | namespace Nwc.XmlRpc | ||
2 | { | ||
3 | using System; | ||
4 | using System.Collections; | ||
5 | using System.Xml; | ||
6 | |||
7 | /// <summary>Class responsible for serializing an XML-RPC response.</summary> | ||
8 | /// <remarks>This class handles the response envelope, depending on XmlRpcSerializer | ||
9 | /// to serialize the payload.</remarks> | ||
10 | /// <seealso cref="XmlRpcSerializer"/> | ||
11 | public class XmlRpcResponseSerializer : XmlRpcSerializer | ||
12 | { | ||
13 | static private XmlRpcResponseSerializer _singleton; | ||
14 | /// <summary>A static singleton instance of this deserializer.</summary> | ||
15 | static public XmlRpcResponseSerializer Singleton | ||
16 | { | ||
17 | get | ||
18 | { | ||
19 | if (_singleton == null) | ||
20 | _singleton = new XmlRpcResponseSerializer(); | ||
21 | |||
22 | return _singleton; | ||
23 | } | ||
24 | } | ||
25 | |||
26 | /// <summary>Serialize the <c>XmlRpcResponse</c> to the output stream.</summary> | ||
27 | /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param> | ||
28 | /// <param name="obj">An <c>Object</c> to serialize.</param> | ||
29 | /// <seealso cref="XmlRpcResponse"/> | ||
30 | override public void Serialize(XmlTextWriter output, Object obj) | ||
31 | { | ||
32 | XmlRpcResponse response = (XmlRpcResponse)obj; | ||
33 | |||
34 | output.WriteStartDocument(); | ||
35 | output.WriteStartElement(METHOD_RESPONSE); | ||
36 | |||
37 | if (response.IsFault) | ||
38 | output.WriteStartElement(FAULT); | ||
39 | else | ||
40 | { | ||
41 | output.WriteStartElement(PARAMS); | ||
42 | output.WriteStartElement(PARAM); | ||
43 | } | ||
44 | |||
45 | output.WriteStartElement(VALUE); | ||
46 | |||
47 | SerializeObject(output, response.Value); | ||
48 | |||
49 | output.WriteEndElement(); | ||
50 | |||
51 | output.WriteEndElement(); | ||
52 | if (!response.IsFault) | ||
53 | output.WriteEndElement(); | ||
54 | output.WriteEndElement(); | ||
55 | } | ||
56 | } | ||
57 | } | ||