aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2007-10-31 09:26:06 +0000
committerMW2007-10-31 09:26:06 +0000
commit720065ef9e28896052cbcc1514ea35e068bda872 (patch)
tree2f48ac8f436ac9b0b0ce7a1e35a5c3870e0a874d /OpenSim
parentsome small changes (diff)
downloadopensim-SC_OLD-720065ef9e28896052cbcc1514ea35e068bda872.zip
opensim-SC_OLD-720065ef9e28896052cbcc1514ea35e068bda872.tar.gz
opensim-SC_OLD-720065ef9e28896052cbcc1514ea35e068bda872.tar.bz2
opensim-SC_OLD-720065ef9e28896052cbcc1514ea35e068bda872.tar.xz
forgotten file
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/RestDeserialiseHandler.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
new file mode 100644
index 0000000..cb500ca
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
@@ -0,0 +1,41 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using System.Xml;
6using System.Xml.Serialization;
7
8namespace OpenSim.Framework.Servers
9{
10 public delegate string RestDeserialiseMethod<TRequest>(TRequest request);
11
12 public class RestDeserialisehandler<TRequest> : BaseStreamHandler
13 where TRequest : new()
14 {
15 private RestDeserialiseMethod<TRequest> m_method;
16
17 public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest> method)
18 : base(httpMethod, path)
19 {
20 m_method = method;
21 }
22
23 public override byte[] Handle(string path, Stream request)
24 {
25 Type type = typeof(TRequest);
26
27 TRequest deserial= default(TRequest);
28 using (XmlTextReader xreader = new XmlTextReader(request))
29 {
30 XmlSerializer serializer = new XmlSerializer(type);
31 deserial = (TRequest)serializer.Deserialize(xreader);
32 }
33
34 string response = m_method(deserial);
35
36 Encoding encoding = new UTF8Encoding(false);
37 return encoding.GetBytes(response);
38
39 }
40 }
41}