aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/XmlRpcCS/XmlRpcRequestDeserializer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--XmlRpcCS/XmlRpcRequestDeserializer.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/XmlRpcCS/XmlRpcRequestDeserializer.cs b/XmlRpcCS/XmlRpcRequestDeserializer.cs
new file mode 100644
index 0000000..0770b7e
--- /dev/null
+++ b/XmlRpcCS/XmlRpcRequestDeserializer.cs
@@ -0,0 +1,64 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.Diagnostics;
6 using System.IO;
7 using System.Xml;
8
9 /// <summary>Class to deserialize XML data representing a request.</summary>
10 public class XmlRpcRequestDeserializer : XmlRpcDeserializer
11 {
12 static private XmlRpcRequestDeserializer _singleton;
13 /// <summary>A static singleton instance of this deserializer.</summary>
14 [Obsolete("This object is now thread safe, just use an instance.", false)]
15 static public XmlRpcRequestDeserializer Singleton
16 {
17 get
18 {
19 if (_singleton == null)
20 _singleton = new XmlRpcRequestDeserializer();
21
22 return _singleton;
23 }
24 }
25
26 /// <summary>Static method that parses XML data into a request using the Singleton.</summary>
27 /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC request.</param>
28 /// <returns><c>XmlRpcRequest</c> object resulting from the parse.</returns>
29 override public Object Deserialize(TextReader xmlData)
30 {
31 XmlTextReader reader = new XmlTextReader(xmlData);
32 XmlRpcRequest request = new XmlRpcRequest();
33 bool done = false;
34
35 lock (this)
36 {
37 Reset();
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 METHOD_NAME:
47 request.MethodName = _text;
48 break;
49 case METHOD_CALL:
50 done = true;
51 break;
52 case PARAM:
53 request.Params.Add(_value);
54 _text = null;
55 break;
56 }
57 break;
58 }
59 }
60 }
61 return request;
62 }
63 }
64}