diff options
Diffstat (limited to 'OpenSim/Framework/Servers/RestDeserialiseHandler.cs')
-rw-r--r-- | OpenSim/Framework/Servers/RestDeserialiseHandler.cs | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs index adf5c3f..a47d3d3 100644 --- a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs +++ b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs | |||
@@ -1,38 +1,38 @@ | |||
1 | using System.IO; | 1 | using System.IO; |
2 | using System.Xml; | 2 | using System.Xml; |
3 | using System.Xml.Serialization; | 3 | using System.Xml.Serialization; |
4 | 4 | ||
5 | namespace OpenSim.Framework.Servers | 5 | namespace OpenSim.Framework.Servers |
6 | { | 6 | { |
7 | public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); | 7 | public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); |
8 | 8 | ||
9 | public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler | 9 | public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler |
10 | where TRequest : new() | 10 | where TRequest : new() |
11 | { | 11 | { |
12 | private RestDeserialiseMethod<TRequest, TResponse> m_method; | 12 | private RestDeserialiseMethod<TRequest, TResponse> m_method; |
13 | 13 | ||
14 | public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) | 14 | public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) |
15 | : base(httpMethod, path) | 15 | : base(httpMethod, path) |
16 | { | 16 | { |
17 | m_method = method; | 17 | m_method = method; |
18 | } | 18 | } |
19 | 19 | ||
20 | public void Handle(string path, Stream request, Stream responseStream) | 20 | public void Handle(string path, Stream request, Stream responseStream) |
21 | { | 21 | { |
22 | TRequest deserial; | 22 | TRequest deserial; |
23 | using (XmlTextReader xmlReader = new XmlTextReader(request)) | 23 | using (XmlTextReader xmlReader = new XmlTextReader(request)) |
24 | { | 24 | { |
25 | XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); | 25 | XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); |
26 | deserial = (TRequest) deserializer.Deserialize(xmlReader); | 26 | deserial = (TRequest) deserializer.Deserialize(xmlReader); |
27 | } | 27 | } |
28 | 28 | ||
29 | TResponse response = m_method(deserial); | 29 | TResponse response = m_method(deserial); |
30 | 30 | ||
31 | using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream)) | 31 | using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream)) |
32 | { | 32 | { |
33 | XmlSerializer serializer = new XmlSerializer(typeof (TResponse)); | 33 | XmlSerializer serializer = new XmlSerializer(typeof (TResponse)); |
34 | serializer.Serialize(xmlWriter, response); | 34 | serializer.Serialize(xmlWriter, response); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | } | 37 | } |
38 | } \ No newline at end of file | 38 | } \ No newline at end of file |