mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
Merged 3Di code that provides scene and avatar serialization, and plugin support for region move/split/merge. See ThirdParty/3Di/README.txt. Unless the new modules are used there should be no noticeable changes when running OpenSim.
This commit is contained in:
@@ -26,10 +26,14 @@
|
||||
*
|
||||
*/
|
||||
using libsecondlife;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class AvatarWearable
|
||||
[Serializable]
|
||||
public class AvatarWearable : ISerializable
|
||||
{
|
||||
public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
|
||||
public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
|
||||
@@ -67,5 +71,32 @@ namespace OpenSim.Framework
|
||||
return defaultWearables;
|
||||
}
|
||||
}
|
||||
protected AvatarWearable(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
//System.Console.WriteLine("AvatarWearable Deserialize BGN");
|
||||
if (info == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("info");
|
||||
}
|
||||
|
||||
AssetID = new LLUUID((Guid)info.GetValue("AssetID", typeof(Guid)));
|
||||
ItemID = new LLUUID((Guid)info.GetValue("ItemID", typeof(Guid)));
|
||||
|
||||
//System.Console.WriteLine("AvatarWearable Deserialize END");
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.LinkDemand,
|
||||
Flags = SecurityPermissionFlag.SerializationFormatter)]
|
||||
public virtual void GetObjectData(
|
||||
SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("info");
|
||||
}
|
||||
|
||||
info.AddValue("AssetID", AssetID.UUID);
|
||||
info.AddValue("ItemID", ItemID.UUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,5 +69,10 @@ namespace OpenSim.Framework
|
||||
{
|
||||
return m_queue.Count;
|
||||
}
|
||||
|
||||
public T[] GetQueueArray()
|
||||
{
|
||||
return m_queue.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
private uint[] GetAllCircuits(LLUUID agentId)
|
||||
public uint[] GetAllCircuits(LLUUID agentId)
|
||||
{
|
||||
List<uint> circuits = new List<uint>();
|
||||
// Wasteful, I know
|
||||
|
||||
@@ -97,6 +97,11 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
database.ExecuteResourceSql("CreateRegionsTable.sql");
|
||||
return;
|
||||
}
|
||||
else if (oldVersion.Contains("Rev. 1"))
|
||||
{
|
||||
database.ExecuteResourceSql("UpgradeRegionsTableToVersion2.sql");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -259,6 +264,27 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a profile from the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to delete</param>
|
||||
/// <returns>Successful?</returns>
|
||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
||||
public DataResponse DeleteProfile(string uuid)
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
if (database.deleteRegion(uuid))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
|
||||
/// </summary>
|
||||
@@ -328,4 +354,4 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,6 +301,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
|
||||
// non-critical parts
|
||||
retval.regionName = (string)reader["regionName"];
|
||||
retval.originUUID = new LLUUID((string) reader["originUUID"]);
|
||||
|
||||
// Secrets
|
||||
retval.regionRecvKey = (string) reader["regionRecvKey"];
|
||||
@@ -752,13 +753,13 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
// server for the UUID of the region's owner (master avatar). It consists of the addition of the column and value to the relevant sql,
|
||||
// as well as the related parameterization
|
||||
sql +=
|
||||
"regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid) VALUES ";
|
||||
"regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID) VALUES ";
|
||||
|
||||
sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, ";
|
||||
sql +=
|
||||
"?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, ";
|
||||
sql +=
|
||||
"?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid)";
|
||||
"?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid, ?originUUID)";
|
||||
|
||||
if (GRID_ONLY_UPDATE_NECESSARY_DATA)
|
||||
{
|
||||
@@ -798,6 +799,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
parameters["?serverHttpPort"] = regiondata.httpPort.ToString();
|
||||
parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString();
|
||||
parameters["?owner_uuid"] = regiondata.owner_uuid.ToString();
|
||||
parameters["?originUUID"] = regiondata.originUUID.ToString();
|
||||
|
||||
bool returnval = false;
|
||||
|
||||
@@ -819,6 +821,42 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
return false;
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
/// <summary>
|
||||
/// Delete a region from the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The region to insert</param>
|
||||
/// <returns>Success?</returns>
|
||||
//public bool deleteRegion(RegionProfileData regiondata)
|
||||
public bool deleteRegion(string uuid)
|
||||
{
|
||||
bool returnval = false;
|
||||
|
||||
string sql =
|
||||
"DELETE FROM regions WHERE uuid = ?uuid;";
|
||||
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||
|
||||
try
|
||||
{
|
||||
parameters["?uuid"] = uuid;
|
||||
|
||||
IDbCommand result = Query(sql, parameters);
|
||||
|
||||
int x;
|
||||
if ((x = result.ExecuteNonQuery()) > 0)
|
||||
{
|
||||
returnval = true;
|
||||
}
|
||||
result.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ CREATE TABLE `regions` (
|
||||
`regionUserRecvKey` varchar(128) default NULL,
|
||||
`regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL,
|
||||
`serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL,
|
||||
`originUUID` varchar(36),
|
||||
PRIMARY KEY (`uuid`),
|
||||
KEY `regionName` (`regionName`),
|
||||
KEY `regionHandle` (`regionHandle`),
|
||||
KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 1';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 2';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `regions`
|
||||
ADD COLUMN `originUUID` varchar(36),
|
||||
COMMENT='Rev. 2';
|
||||
@@ -129,6 +129,12 @@ namespace OpenSim.Framework.Data
|
||||
/// </summary>
|
||||
public LLUUID owner_uuid = LLUUID.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// OGS/OpenSim Specific original ID for a region after move/split
|
||||
/// </summary>
|
||||
public LLUUID originUUID;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get Sim profile data from grid server when in grid mode
|
||||
/// </summary>
|
||||
@@ -162,7 +168,7 @@ namespace OpenSim.Framework.Data
|
||||
simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
|
||||
simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
|
||||
simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
|
||||
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
|
||||
simData.serverURI = (string)responseData["server_uri"];
|
||||
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
|
||||
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
|
||||
simData.regionName = (string) responseData["region_name"];
|
||||
@@ -205,7 +211,7 @@ namespace OpenSim.Framework.Data
|
||||
simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
|
||||
simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
|
||||
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
|
||||
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
|
||||
simData.serverURI = (string)responseData["server_uri"];
|
||||
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
|
||||
simData.regionName = (string) responseData["region_name"];
|
||||
|
||||
|
||||
@@ -665,5 +665,24 @@ namespace OpenSim.Framework
|
||||
void SendBlueBoxMessage(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message);
|
||||
|
||||
void SendLogoutPacket();
|
||||
ClientInfo GetClientInfo();
|
||||
void SetClientInfo(ClientInfo info);
|
||||
void Terminate();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ClientInfo
|
||||
{
|
||||
public byte[] usecircuit;
|
||||
public EndPoint userEP;
|
||||
public EndPoint proxyEP;
|
||||
public sAgentCircuitData agentcircuit;
|
||||
|
||||
public Dictionary<uint, uint> pendingAcks;
|
||||
public Dictionary<uint, byte[]> needAck;
|
||||
|
||||
public List<byte[]> out_packets;
|
||||
|
||||
public uint sequence;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace OpenSim.Framework
|
||||
Down = 0,
|
||||
Up = 1,
|
||||
Crashed = 2,
|
||||
Starting = 3
|
||||
Starting = 3,
|
||||
SlaveScene = 4
|
||||
} ;
|
||||
|
||||
public interface IScene
|
||||
@@ -63,4 +64,4 @@ namespace OpenSim.Framework
|
||||
|
||||
ClientManager ClientManager { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Collections;
|
||||
using libsecondlife.Packets;
|
||||
|
||||
@@ -33,29 +34,68 @@ namespace OpenSim.Framework
|
||||
{
|
||||
public sealed class PacketPool
|
||||
{
|
||||
static public void EncodeProxyMessage(byte[] bytes, ref int numBytes, EndPoint trueEP)
|
||||
{
|
||||
if( numBytes > 4090 ) // max UPD size = 4096
|
||||
{
|
||||
throw new Exception("ERROR: No space to encode the proxy EP");
|
||||
}
|
||||
|
||||
ushort port = (ushort) ((IPEndPoint) trueEP).Port;
|
||||
bytes[numBytes++] = (byte)(port % 256);
|
||||
bytes[numBytes++] = (byte)(port / 256);
|
||||
|
||||
foreach (byte b in ((IPEndPoint)trueEP).Address.GetAddressBytes())
|
||||
{
|
||||
bytes[numBytes++] = b;
|
||||
}
|
||||
|
||||
int x = numBytes;
|
||||
|
||||
DecodeProxyMessage(bytes, ref numBytes);
|
||||
|
||||
numBytes = x;
|
||||
}
|
||||
|
||||
static public EndPoint DecodeProxyMessage(byte[] bytes, ref int numBytes)
|
||||
{
|
||||
// IPv4 Only
|
||||
byte[] addr = new byte[4];
|
||||
|
||||
addr[3] = bytes[--numBytes];
|
||||
addr[2] = bytes[--numBytes];
|
||||
addr[1] = bytes[--numBytes];
|
||||
addr[0] = bytes[--numBytes];
|
||||
|
||||
ushort port = (ushort)(bytes[--numBytes] * 256);
|
||||
port += (ushort)bytes[--numBytes];
|
||||
|
||||
return (EndPoint) new IPEndPoint(new IPAddress(addr), (int)port);
|
||||
}
|
||||
|
||||
// Set up a thread-safe singleton pattern
|
||||
static PacketPool()
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly PacketPool instance = new PacketPool();
|
||||
static readonly PacketPool instance = new PacketPool();
|
||||
|
||||
public static PacketPool Instance
|
||||
{
|
||||
get { return instance; }
|
||||
get
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private Hashtable pool = new Hashtable();
|
||||
|
||||
public Packet GetPacket(PacketType type)
|
||||
{
|
||||
return Packet.BuildPacket(type);
|
||||
/* Skip until PacketPool performance problems have been resolved (mantis 281)
|
||||
public Packet GetPacket(PacketType type) {
|
||||
Packet packet = null;
|
||||
|
||||
lock (pool)
|
||||
lock(pool)
|
||||
{
|
||||
if (pool[type] == null || ((Stack) pool[type]).Count == 0)
|
||||
if(pool[type] == null || ((Stack) pool[type]).Count == 0)
|
||||
{
|
||||
// Creating a new packet if we cannot reuse an old package
|
||||
packet = Packet.BuildPacket(type);
|
||||
@@ -63,39 +103,16 @@ namespace OpenSim.Framework
|
||||
else
|
||||
{
|
||||
// Recycle old packages
|
||||
packet = (Packet) ((Stack) pool[type]).Pop();
|
||||
packet=(Packet) ((Stack) pool[type]).Pop();
|
||||
}
|
||||
}
|
||||
|
||||
return packet;
|
||||
*/
|
||||
}
|
||||
|
||||
// Copied from LibSL, and added a check to avoid overwriting the
|
||||
// buffer
|
||||
private void ZeroDecodeCommand(byte[] src, byte[] dest)
|
||||
{
|
||||
for (int srcPos = 6, destPos = 6; destPos < 10; ++srcPos)
|
||||
{
|
||||
if (src[srcPos] == 0x00)
|
||||
{
|
||||
for (byte j = 0; j < src[srcPos + 1] && destPos < 10; ++j)
|
||||
{
|
||||
dest[destPos++] = 0x00;
|
||||
}
|
||||
++srcPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest[destPos++] = src[srcPos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] decoded_header = new byte[10];
|
||||
private PacketType GetType(byte[] bytes)
|
||||
{
|
||||
byte[] decoded_header = new byte[10];
|
||||
|
||||
ushort id;
|
||||
libsecondlife.PacketFrequency freq;
|
||||
|
||||
@@ -103,7 +120,7 @@ namespace OpenSim.Framework
|
||||
|
||||
if((bytes[0] & libsecondlife.Helpers.MSG_ZEROCODED)!=0)
|
||||
{
|
||||
ZeroDecodeCommand(bytes, decoded_header);
|
||||
libsecondlife.Helpers.ZeroDecodeCommand(bytes, decoded_header);
|
||||
}
|
||||
|
||||
if (decoded_header[6] == 0xFF)
|
||||
@@ -138,21 +155,22 @@ namespace OpenSim.Framework
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void ReturnPacket(Packet packet)
|
||||
{
|
||||
/* Skip until PacketPool performance problems have been resolved (mantis 281)
|
||||
lock (pool)
|
||||
{
|
||||
PacketType type = packet.Type;
|
||||
public void ReturnPacket(Packet packet) {
|
||||
return; // packet pool disabled
|
||||
|
||||
if (pool[type] == null)
|
||||
lock(pool)
|
||||
{
|
||||
PacketType type=packet.Type;
|
||||
|
||||
if(pool[type] == null)
|
||||
{
|
||||
pool[type] = new Stack();
|
||||
}
|
||||
|
||||
((Stack) pool[type]).Push(packet);
|
||||
if (((Stack)pool[type]).Count < 50)
|
||||
{
|
||||
((Stack)pool[type]).Push(packet);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace OpenSim.Framework
|
||||
m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
|
||||
RemotingAddress = ConvertFrom.RemotingAddress;
|
||||
RegionID = LLUUID.Zero;
|
||||
ServerURI = ConvertFrom.ServerURI;
|
||||
}
|
||||
|
||||
public LLUUID RegionID = LLUUID.Zero;
|
||||
@@ -84,6 +85,19 @@ namespace OpenSim.Framework
|
||||
}
|
||||
public bool m_allow_alternate_ports;
|
||||
|
||||
public string m_serverURI;
|
||||
public string ServerURI
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_serverURI;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_serverURI = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string RemotingAddress;
|
||||
|
||||
public IPEndPoint ExternalEndPoint
|
||||
@@ -175,6 +189,8 @@ namespace OpenSim.Framework
|
||||
public string MasterAvatarFirstName = String.Empty;
|
||||
public string MasterAvatarLastName = String.Empty;
|
||||
public string MasterAvatarSandboxPassword = String.Empty;
|
||||
public string proxyUrl = "";
|
||||
public LLUUID originRegionID = LLUUID.Zero;
|
||||
|
||||
// Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
|
||||
private EstateSettings m_estateSettings;
|
||||
@@ -227,6 +243,10 @@ namespace OpenSim.Framework
|
||||
m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
|
||||
RemotingAddress = ConvertFrom.RemotingAddress;
|
||||
RegionID = LLUUID.Zero;
|
||||
proxyUrl = ConvertFrom.ProxyUrl;
|
||||
originRegionID = ConvertFrom.OriginRegionID;
|
||||
RegionName = ConvertFrom.RegionName;
|
||||
ServerURI = ConvertFrom.ServerURI;
|
||||
}
|
||||
|
||||
public RegionInfo(SimpleRegionInfo ConvertFrom)
|
||||
@@ -239,6 +259,7 @@ namespace OpenSim.Framework
|
||||
m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
|
||||
RemotingAddress = ConvertFrom.RemotingAddress;
|
||||
RegionID = LLUUID.Zero;
|
||||
ServerURI = ConvertFrom.ServerURI;
|
||||
}
|
||||
|
||||
//not in use, should swap to nini though.
|
||||
@@ -411,4 +432,4 @@ namespace OpenSim.Framework
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace OpenSim.Framework
|
||||
m_remotingPort = ConvertFrom.RemotingPort;
|
||||
m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
|
||||
RemotingAddress = ConvertFrom.RemotingAddress;
|
||||
m_proxyUrl = ConvertFrom.proxyUrl;
|
||||
OriginRegionID = ConvertFrom.originRegionID;
|
||||
RegionName = ConvertFrom.RegionName;
|
||||
ServerURI = ConvertFrom.ServerURI;
|
||||
}
|
||||
|
||||
public SearializableRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
|
||||
@@ -157,5 +161,57 @@ namespace OpenSim.Framework
|
||||
{
|
||||
get { return Util.UIntsToLong((RegionLocX * (uint)Constants.RegionSize), (RegionLocY * (uint)Constants.RegionSize)); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected string m_proxyUrl;
|
||||
public string ProxyUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_proxyUrl;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_proxyUrl = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected Guid m_originRegionID = LLUUID.Zero.UUID;
|
||||
public LLUUID OriginRegionID
|
||||
{
|
||||
get
|
||||
{
|
||||
return new LLUUID(m_originRegionID);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_originRegionID = value.UUID;
|
||||
}
|
||||
}
|
||||
|
||||
protected string m_regionName;
|
||||
public string RegionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_regionName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_regionName = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected string m_serverURI;
|
||||
public string ServerURI
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_serverURI;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_serverURI = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ using System.Text;
|
||||
using libsecondlife;
|
||||
using Nini.Config;
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class Util
|
||||
@@ -509,7 +511,63 @@ namespace OpenSim.Framework
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static void SerializeToFile(string filename, Object obj)
|
||||
{
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
Stream stream = null;
|
||||
|
||||
try
|
||||
{
|
||||
stream = new FileStream(
|
||||
filename, FileMode.Create,
|
||||
FileAccess.Write, FileShare.None);
|
||||
|
||||
formatter.Serialize(stream, obj);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Console.WriteLine(e.Message);
|
||||
System.Console.WriteLine(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object DeserializeFromFile(string filename)
|
||||
{
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
Stream stream = null;
|
||||
Object ret = null;
|
||||
|
||||
try
|
||||
{
|
||||
stream = new FileStream(
|
||||
filename, FileMode.Open,
|
||||
FileAccess.Read, FileShare.None);
|
||||
|
||||
ret = formatter.Deserialize(stream);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Console.WriteLine(e.Message);
|
||||
System.Console.WriteLine(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user