* Various refactorings.

0.6.0-stable
Adam Frisby 2008-04-21 09:38:51 +00:00
parent f741a62d54
commit a0b8c46ef3
2 changed files with 36 additions and 18 deletions

View File

@ -163,7 +163,7 @@ namespace OpenSim.Region.Environment.Modules
// setup response to client
Hashtable creds = new Hashtable();
creds["channel_uri"] = String.Format("sip:{0}@{1}",
m_scene.RegionInfo.RegionID.ToString(), m_sipDomain);
m_scene.RegionInfo.RegionID, m_sipDomain);
string regionName = m_scene.RegionInfo.RegionName;
ScenePresence avatar = m_scene.GetScenePresence(agentID);
@ -207,8 +207,6 @@ namespace OpenSim.Region.Environment.Modules
return "<llsd>undef</llsd>";
}
return null;
}
/// <summary>
@ -282,8 +280,6 @@ namespace OpenSim.Region.Environment.Modules
return "<llsd>undef</llsd>";
}
return null;
}
}
}

View File

@ -50,6 +50,32 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
#endregion
public void SaveSerialisedToFile(string fileName, Scene scene)
{
string xmlstream = GetObjectXml(scene);
MemoryStream stream = ReformatXmlString(xmlstream);
stream.Seek(0, SeekOrigin.Begin);
CreateXmlFile(stream, fileName);
stream.Seek(0, SeekOrigin.Begin);
CreateCompressedXmlFile(stream, fileName);
}
private static MemoryStream ReformatXmlString(string xmlstream)
{
MemoryStream stream = new MemoryStream();
XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8);
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlstream);
formatter.Formatting = Formatting.Indented;
doc.WriteContentTo(formatter);
formatter.Flush();
return stream;
}
private static string GetObjectXml(Scene scene)
{
string xmlstream = "<scene>";
@ -69,29 +95,25 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
xmlstream += xml;
xmlstream += "</scene>";
return xmlstream;
}
MemoryStream stream = new MemoryStream();
XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8);
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlstream);
formatter.Formatting = Formatting.Indented;
doc.WriteContentTo(formatter);
formatter.Flush();
stream.Seek(0, SeekOrigin.Begin);
private static void CreateXmlFile(MemoryStream xmlStream, string fileName)
{
FileStream objectsFile = new FileStream(fileName, FileMode.Create);
stream.WriteTo(objectsFile);
xmlStream.WriteTo(objectsFile);
objectsFile.Flush();
objectsFile.Close();
}
private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
{
#region GZip Compressed Version
FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
MemoryStream gzipMSStream = new MemoryStream();
GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
stream.WriteTo(gzipStream);
xmlStream.WriteTo(gzipStream);
gzipMSStream.WriteTo(objectsFileCompressed);
objectsFileCompressed.Flush();
objectsFileCompressed.Close();