* Optimized usings

* Shortened type references
* Removed redundant 'this' qualifier
This commit is contained in:
lbsa71
2007-10-30 09:05:31 +00:00
parent c32d1f0562
commit 67e12b95ea
353 changed files with 15459 additions and 10338 deletions

View File

@@ -31,11 +31,10 @@ using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using Nwc.XmlRpc;
using OpenSim.Framework.Console;
using System.Xml;
namespace OpenSim.Framework.Servers
{
@@ -50,7 +49,7 @@ namespace OpenSim.Framework.Servers
public int Port
{
get { return m_port; }
get { return m_port; }
}
public BaseHttpServer(int port)
@@ -58,11 +57,11 @@ namespace OpenSim.Framework.Servers
m_port = port;
}
public void AddStreamHandler( IStreamHandler handler)
public void AddStreamHandler(IStreamHandler handler)
{
string httpMethod = handler.HttpMethod;
string path = handler.Path;
string handlerKey = GetHandlerKey(httpMethod, path);
m_streamHandlers.Add(handlerKey, handler);
}
@@ -74,9 +73,9 @@ namespace OpenSim.Framework.Servers
public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
{
if (!this.m_rpcHandlers.ContainsKey(method))
if (!m_rpcHandlers.ContainsKey(method))
{
this.m_rpcHandlers.Add(method, handler);
m_rpcHandlers.Add(method, handler);
return true;
}
@@ -87,7 +86,7 @@ namespace OpenSim.Framework.Servers
public virtual void HandleRequest(Object stateinfo)
{
HttpListenerContext context = (HttpListenerContext)stateinfo;
HttpListenerContext context = (HttpListenerContext) stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
@@ -96,11 +95,11 @@ namespace OpenSim.Framework.Servers
response.SendChunked = false;
string path = request.RawUrl;
string handlerKey = GetHandlerKey( request.HttpMethod, path );
string handlerKey = GetHandlerKey(request.HttpMethod, path);
IStreamHandler streamHandler;
if (TryGetStreamHandler( handlerKey, out streamHandler))
if (TryGetStreamHandler(handlerKey, out streamHandler))
{
byte[] buffer = streamHandler.Handle(path, request.InputStream);
request.InputStream.Close();
@@ -159,11 +158,11 @@ namespace OpenSim.Framework.Servers
try
{
xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
}
catch ( XmlException e )
{
responseString = String.Format( "XmlException:\n{0}",e.Message );
catch (XmlException e)
{
responseString = String.Format("XmlException:\n{0}", e.Message);
}
if (xmlRprcRequest != null)
@@ -173,7 +172,7 @@ namespace OpenSim.Framework.Servers
XmlRpcResponse xmlRpcResponse;
XmlRpcMethod method;
if (this.m_rpcHandlers.TryGetValue(methodName, out method))
if (m_rpcHandlers.TryGetValue(methodName, out method))
{
xmlRpcResponse = method(xmlRprcRequest);
}
@@ -181,7 +180,8 @@ namespace OpenSim.Framework.Servers
{
xmlRpcResponse = new XmlRpcResponse();
Hashtable unknownMethodError = new Hashtable();
unknownMethodError["reason"] = "XmlRequest"; ;
unknownMethodError["reason"] = "XmlRequest";
;
unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]";
unknownMethodError["login"] = "false";
xmlRpcResponse.Value = unknownMethodError;
@@ -249,4 +249,4 @@ namespace OpenSim.Framework.Servers
m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
}
}
}
}

View File

@@ -26,37 +26,36 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace OpenSim.Framework.Servers
{
public abstract class BaseStreamHandler : IStreamHandler
{
virtual public string ContentType
public virtual string ContentType
{
get { return "application/xml"; }
}
private string m_httpMethod;
virtual public string HttpMethod
public virtual string HttpMethod
{
get { return m_httpMethod; }
}
private string m_path;
virtual public string Path
public virtual string Path
{
get { return m_path; }
}
protected string GetParam( string path )
protected string GetParam(string path)
{
return path.Substring( m_path.Length );
return path.Substring(m_path.Length);
}
public abstract byte[] Handle(string path, Stream request);
protected BaseStreamHandler(string httpMethod, string path)
@@ -65,4 +64,4 @@ namespace OpenSim.Framework.Servers
m_path = path;
}
}
}
}

View File

@@ -26,10 +26,8 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text;
namespace OpenSim.Framework.Servers
{
@@ -37,14 +35,14 @@ namespace OpenSim.Framework.Servers
public class BinaryStreamHandler : BaseStreamHandler
{
BinaryMethod m_method;
private BinaryMethod m_method;
override public byte[] Handle(string path, Stream request)
public override byte[] Handle(string path, Stream request)
{
byte[] data = ReadFully(request);
string param = GetParam(path);
string responseString = m_method(data, path, param);
return Encoding.UTF8.GetBytes(responseString);
}
@@ -67,11 +65,10 @@ namespace OpenSim.Framework.Servers
{
return ms.ToArray();
}
ms.Write(buffer, 0, read);
}
}
}
}
}
}
}

View File

@@ -26,7 +26,8 @@
*
*/
namespace OpenSim.Framework.Servers
{/*
{
/*
public class CheckSumServer : UDPServerBase
{
//protected ConsoleBase m_log;
@@ -123,5 +124,4 @@ namespace OpenSim.Framework.Servers
}
* }
*/
}

View File

@@ -26,9 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace OpenSim.Framework.Servers
@@ -36,15 +33,15 @@ namespace OpenSim.Framework.Servers
public interface IStreamHandler
{
// Handle request stream, return byte array
byte[] Handle(string path, Stream request );
byte[] Handle(string path, Stream request);
// Return response content type
string ContentType { get; }
// Return required http method
string HttpMethod { get;}
string HttpMethod { get; }
// Return path
string Path { get; }
}
}
}

View File

@@ -27,5 +27,5 @@
*/
namespace OpenSim.Framework.Servers
{
public delegate string RestMethod( string request, string path, string param );
}
public delegate string RestMethod(string request, string path, string param);
}

View File

@@ -26,18 +26,16 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text;
namespace OpenSim.Framework.Servers
{
public class RestStreamHandler : BaseStreamHandler
{
RestMethod m_restMethod;
private RestMethod m_restMethod;
override public byte[] Handle(string path, Stream request )
public override byte[] Handle(string path, Stream request)
{
Encoding encoding = Encoding.UTF8;
StreamReader streamReader = new StreamReader(request, encoding);
@@ -46,14 +44,14 @@ namespace OpenSim.Framework.Servers
streamReader.Close();
string param = GetParam(path);
string responseString = m_restMethod(requestBody, path, param );
string responseString = m_restMethod(requestBody, path, param);
return Encoding.UTF8.GetBytes(responseString);
}
public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path )
public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base(httpMethod, path)
{
m_restMethod = restMethod;
}
}
}
}

View File

@@ -51,7 +51,7 @@ namespace OpenSim.Framework.Servers
protected virtual void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
epSender = (EndPoint)ipeSender;
epSender = (EndPoint) ipeSender;
Packet packet = null;
int numBytes = Server.EndReceiveFrom(result, ref epSender);
int packetEnd = numBytes - 1;
@@ -67,21 +67,18 @@ namespace OpenSim.Framework.Servers
public virtual void ServerListener()
{
ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Server.Bind(ServerIncoming);
ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
epSender = (EndPoint)ipeSender;
ReceivedData = new AsyncCallback(this.OnReceivedData);
epSender = (EndPoint) ipeSender;
ReceivedData = new AsyncCallback(OnReceivedData);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
{
}
}
}
}

View File

@@ -29,5 +29,5 @@ using Nwc.XmlRpc;
namespace OpenSim.Framework.Servers
{
public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
}
public delegate XmlRpcResponse XmlRpcMethod(XmlRpcRequest request);
}