diff options
Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server.
Diffstat (limited to 'Common-Source/XmlRpcCS/XmlRpcResponseDeserializer.cs')
-rw-r--r-- | Common-Source/XmlRpcCS/XmlRpcResponseDeserializer.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Common-Source/XmlRpcCS/XmlRpcResponseDeserializer.cs b/Common-Source/XmlRpcCS/XmlRpcResponseDeserializer.cs new file mode 100644 index 0000000..032d8a3 --- /dev/null +++ b/Common-Source/XmlRpcCS/XmlRpcResponseDeserializer.cs | |||
@@ -0,0 +1,65 @@ | |||
1 | namespace Nwc.XmlRpc | ||
2 | { | ||
3 | using System; | ||
4 | using System.Collections; | ||
5 | using System.IO; | ||
6 | using System.Xml; | ||
7 | |||
8 | /// <summary>Class to deserialize XML data representing a response.</summary> | ||
9 | public class XmlRpcResponseDeserializer : XmlRpcDeserializer | ||
10 | { | ||
11 | static private XmlRpcResponseDeserializer _singleton; | ||
12 | /// <summary>A static singleton instance of this deserializer.</summary> | ||
13 | [Obsolete("This object is now thread safe, just use an instance.", false)] | ||
14 | static public XmlRpcResponseDeserializer Singleton | ||
15 | { | ||
16 | get | ||
17 | { | ||
18 | if (_singleton == null) | ||
19 | _singleton = new XmlRpcResponseDeserializer(); | ||
20 | |||
21 | return _singleton; | ||
22 | } | ||
23 | } | ||
24 | |||
25 | /// <summary>Static method that parses XML data into a response using the Singleton.</summary> | ||
26 | /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param> | ||
27 | /// <returns><c>XmlRpcResponse</c> object resulting from the parse.</returns> | ||
28 | override public Object Deserialize(TextReader xmlData) | ||
29 | { | ||
30 | XmlTextReader reader = new XmlTextReader(xmlData); | ||
31 | XmlRpcResponse response = new XmlRpcResponse(); | ||
32 | bool done = false; | ||
33 | |||
34 | lock (this) | ||
35 | { | ||
36 | Reset(); | ||
37 | |||
38 | while (!done && reader.Read()) | ||
39 | { | ||
40 | DeserializeNode(reader); // Parent parse... | ||
41 | switch (reader.NodeType) | ||
42 | { | ||
43 | case XmlNodeType.EndElement: | ||
44 | switch (reader.Name) | ||
45 | { | ||
46 | case FAULT: | ||
47 | response.Value = _value; | ||
48 | response.IsFault = true; | ||
49 | break; | ||
50 | case PARAM: | ||
51 | response.Value = _value; | ||
52 | _value = null; | ||
53 | _text = null; | ||
54 | break; | ||
55 | } | ||
56 | break; | ||
57 | default: | ||
58 | break; | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | return response; | ||
63 | } | ||
64 | } | ||
65 | } | ||