normalized line endings

This commit is contained in:
Jeff Ames
2007-11-04 14:34:45 +00:00
parent e50a2e2ce2
commit 2d1c255e8c
8 changed files with 1197 additions and 1197 deletions

View File

@@ -1,35 +1,35 @@
namespace OpenSim.Framework.Servers
{
public class BaseRequestHandler
{
public virtual string ContentType
{
get { return "application/xml"; }
}
private readonly string m_httpMethod;
public virtual string HttpMethod
{
get { return m_httpMethod; }
}
private readonly string m_path;
protected BaseRequestHandler(string httpMethod, string path)
{
m_httpMethod = httpMethod;
m_path = path;
}
public virtual string Path
{
get { return m_path; }
}
protected string GetParam(string path)
{
return path.Substring(m_path.Length);
}
}
namespace OpenSim.Framework.Servers
{
public class BaseRequestHandler
{
public virtual string ContentType
{
get { return "application/xml"; }
}
private readonly string m_httpMethod;
public virtual string HttpMethod
{
get { return m_httpMethod; }
}
private readonly string m_path;
protected BaseRequestHandler(string httpMethod, string path)
{
m_httpMethod = httpMethod;
m_path = path;
}
public virtual string Path
{
get { return m_path; }
}
protected string GetParam(string path)
{
return path.Substring(m_path.Length);
}
}
}

View File

@@ -1,38 +1,38 @@
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace OpenSim.Framework.Servers
{
public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
where TRequest : new()
{
private RestDeserialiseMethod<TRequest, TResponse> m_method;
public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method)
: base(httpMethod, path)
{
m_method = method;
}
public void Handle(string path, Stream request, Stream responseStream)
{
TRequest deserial;
using (XmlTextReader xmlReader = new XmlTextReader(request))
{
XmlSerializer deserializer = new XmlSerializer(typeof (TRequest));
deserial = (TRequest) deserializer.Deserialize(xmlReader);
}
TResponse response = m_method(deserial);
using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream))
{
XmlSerializer serializer = new XmlSerializer(typeof (TResponse));
serializer.Serialize(xmlWriter, response);
}
}
}
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace OpenSim.Framework.Servers
{
public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
where TRequest : new()
{
private RestDeserialiseMethod<TRequest, TResponse> m_method;
public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method)
: base(httpMethod, path)
{
m_method = method;
}
public void Handle(string path, Stream request, Stream responseStream)
{
TRequest deserial;
using (XmlTextReader xmlReader = new XmlTextReader(request))
{
XmlSerializer deserializer = new XmlSerializer(typeof (TRequest));
deserial = (TRequest) deserializer.Deserialize(xmlReader);
}
TResponse response = m_method(deserial);
using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream))
{
XmlSerializer serializer = new XmlSerializer(typeof (TResponse));
serializer.Serialize(xmlWriter, response);
}
}
}
}

View File

@@ -1,49 +1,49 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace OpenSim.Framework.Servers
{
public class RestObjectPoster
{
public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
{
Type type = typeof(TRequest);
WebRequest request = WebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "text/xml";
MemoryStream buffer = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
using (XmlWriter writer = XmlWriter.Create(buffer, settings))
{
XmlSerializer serializer = new XmlSerializer(type);
serializer.Serialize(writer, obj);
writer.Flush();
}
int length = (int)buffer.Length;
request.ContentLength = length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length);
IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
}
private static void AsyncCallback(IAsyncResult result)
{
WebRequest request = (WebRequest)result.AsyncState;
using (WebResponse resp = request.EndGetResponse(result))
{
}
}
}
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace OpenSim.Framework.Servers
{
public class RestObjectPoster
{
public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
{
Type type = typeof(TRequest);
WebRequest request = WebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "text/xml";
MemoryStream buffer = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
using (XmlWriter writer = XmlWriter.Create(buffer, settings))
{
XmlSerializer serializer = new XmlSerializer(type);
serializer.Serialize(writer, obj);
writer.Flush();
}
int length = (int)buffer.Length;
request.ContentLength = length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length);
IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
}
private static void AsyncCallback(IAsyncResult result)
{
WebRequest request = (WebRequest)result.AsyncState;
using (WebResponse resp = request.EndGetResponse(result))
{
}
}
}
}