mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 11:33:28 +08:00
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
This commit is contained in:
@@ -29,17 +29,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using libsecondlife;
|
||||
using Nini.Config;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
namespace OpenSim.Grid.AssetServer
|
||||
@@ -79,11 +72,12 @@ namespace OpenSim.Grid.AssetServer
|
||||
|
||||
private OpenAsset_Main()
|
||||
{
|
||||
if(!Directory.Exists(Util.logDir()))
|
||||
if (!Directory.Exists(Util.logDir()))
|
||||
{
|
||||
Directory.CreateDirectory(Util.logDir());
|
||||
}
|
||||
m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-AssetServer-console.log")), "OpenAsset", this, true);
|
||||
m_console =
|
||||
new LogBase((Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), "OpenAsset", this, true);
|
||||
MainLog.Instance = m_console;
|
||||
}
|
||||
|
||||
@@ -96,9 +90,9 @@ namespace OpenSim.Grid.AssetServer
|
||||
|
||||
m_console.Verbose("ASSET", "Loading default asset set..");
|
||||
LoadDefaultAssets();
|
||||
|
||||
|
||||
m_console.Verbose("ASSET", "Starting HTTP process");
|
||||
BaseHttpServer httpServer = new BaseHttpServer((int)m_config.HttpPort);
|
||||
BaseHttpServer httpServer = new BaseHttpServer((int) m_config.HttpPort);
|
||||
|
||||
httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider));
|
||||
httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider));
|
||||
@@ -125,7 +119,8 @@ namespace OpenSim.Grid.AssetServer
|
||||
|
||||
if (typeInterface != null)
|
||||
{
|
||||
IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
IAssetProvider plug =
|
||||
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
assetPlugin = plug;
|
||||
assetPlugin.Initialise();
|
||||
|
||||
@@ -174,7 +169,7 @@ namespace OpenSim.Grid.AssetServer
|
||||
FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
||||
byte[] idata = new byte[numBytes];
|
||||
BinaryReader br = new BinaryReader(fStream);
|
||||
idata = br.ReadBytes((int)numBytes);
|
||||
idata = br.ReadBytes((int) numBytes);
|
||||
br.Close();
|
||||
fStream.Close();
|
||||
info.Data = idata;
|
||||
@@ -213,8 +208,8 @@ namespace OpenSim.Grid.AssetServer
|
||||
{
|
||||
string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
|
||||
string name = source.Configs[i].GetString("name", "");
|
||||
sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0);
|
||||
sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0);
|
||||
sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
|
||||
sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
|
||||
string fileName = source.Configs[i].GetString("fileName", "");
|
||||
|
||||
AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
|
||||
@@ -247,4 +242,4 @@ namespace OpenSim.Grid.AssetServer
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,25 +27,29 @@
|
||||
*/
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OGS-AssetServer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OGS-AssetServer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly : AssemblyTitle("OGS-AssetServer")]
|
||||
[assembly : AssemblyDescription("")]
|
||||
[assembly : AssemblyConfiguration("")]
|
||||
[assembly : AssemblyCompany("")]
|
||||
[assembly : AssemblyProduct("OGS-AssetServer")]
|
||||
[assembly : AssemblyCopyright("Copyright © 2007")]
|
||||
[assembly : AssemblyTrademark("")]
|
||||
[assembly : AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly : ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
|
||||
|
||||
[assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
@@ -54,5 +58,6 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
[assembly : AssemblyVersion("1.0.0.0")]
|
||||
[assembly : AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,29 +1,27 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Text;
|
||||
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
namespace OpenSim.Grid.AssetServer
|
||||
{
|
||||
public class GetAssetStreamHandler : BaseStreamHandler
|
||||
{
|
||||
OpenAsset_Main m_assetManager;
|
||||
IAssetProvider m_assetProvider;
|
||||
private OpenAsset_Main m_assetManager;
|
||||
private IAssetProvider m_assetProvider;
|
||||
|
||||
override public byte[] Handle(string path, Stream request)
|
||||
public override byte[] Handle(string path, Stream request)
|
||||
{
|
||||
string param = GetParam(path);
|
||||
byte[] result = new byte[] { };
|
||||
try {
|
||||
|
||||
string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] result = new byte[] {};
|
||||
try
|
||||
{
|
||||
string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (p.Length > 0)
|
||||
{
|
||||
@@ -42,7 +40,7 @@ namespace OpenSim.Grid.AssetServer
|
||||
{
|
||||
MainLog.Instance.Debug("REST", "GET:/asset found {0}, {1}", assetID, asset.Name);
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
|
||||
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
|
||||
MemoryStream ms = new MemoryStream();
|
||||
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
|
||||
xw.Formatting = Formatting.Indented;
|
||||
@@ -53,7 +51,7 @@ namespace OpenSim.Grid.AssetServer
|
||||
StreamReader sr = new StreamReader(ms);
|
||||
|
||||
result = ms.GetBuffer();
|
||||
Array.Resize<byte>(ref result, (int)ms.Length);
|
||||
Array.Resize<byte>(ref result, (int) ms.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -69,7 +67,7 @@ namespace OpenSim.Grid.AssetServer
|
||||
}
|
||||
|
||||
public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
|
||||
: base("GET", "/assets" )
|
||||
: base("GET", "/assets")
|
||||
{
|
||||
m_assetManager = assetManager;
|
||||
m_assetProvider = assetProvider;
|
||||
@@ -78,25 +76,25 @@ namespace OpenSim.Grid.AssetServer
|
||||
|
||||
public class PostAssetStreamHandler : BaseStreamHandler
|
||||
{
|
||||
OpenAsset_Main m_assetManager;
|
||||
IAssetProvider m_assetProvider;
|
||||
private OpenAsset_Main m_assetManager;
|
||||
private IAssetProvider m_assetProvider;
|
||||
|
||||
override public byte[] Handle(string path, Stream request)
|
||||
public override byte[] Handle(string path, Stream request)
|
||||
{
|
||||
string param = GetParam(path);
|
||||
|
||||
|
||||
LLUUID assetId;
|
||||
if(param.Length > 0)
|
||||
if (param.Length > 0)
|
||||
LLUUID.TryParse(param, out assetId);
|
||||
byte[] txBuffer = new byte[4096];
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
|
||||
AssetBase asset = (AssetBase)xs.Deserialize(request);
|
||||
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
|
||||
AssetBase asset = (AssetBase) xs.Deserialize(request);
|
||||
|
||||
MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID);
|
||||
m_assetProvider.CreateAsset(asset);
|
||||
|
||||
return new byte[] { };
|
||||
return new byte[] {};
|
||||
}
|
||||
|
||||
public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
|
||||
@@ -106,4 +104,4 @@ namespace OpenSim.Grid.AssetServer
|
||||
m_assetProvider = assetProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user