From 303aa4b65ead33c44122d61c0f9ef075236e6f76 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 14 May 2009 18:08:54 +0000
Subject: * refactor: move bottom part of 'xml2' serializaton to separate class
---
.../Framework/Interfaces/IInterregionComms.cs | 3 +-
.../Region/Framework/Scenes/SceneObjectGroup.cs | 27 ------
.../Scenes/Serialization/SceneObjectSerializer.cs | 105 +++++++++++++--------
3 files changed, 67 insertions(+), 68 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
index 95b1079..34b8aac 100644
--- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
@@ -35,7 +35,6 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IInterregionCommsOut
{
-
#region Agents
bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason);
@@ -87,7 +86,7 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall);
+ bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall);
///
/// Create an object from the user's inventory in the destination region.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5611b03..8a06fd1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -583,33 +583,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
- public void ToXml2(XmlTextWriter writer)
- {
- //m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name);
- //int time = System.Environment.TickCount;
-
- writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
- m_rootPart.ToXml(writer);
- writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
-
- lock (m_parts)
- {
- foreach (SceneObjectPart part in m_parts.Values)
- {
- if (part.UUID != m_rootPart.UUID)
- {
- part.ToXml(writer);
- }
- }
- }
-
- writer.WriteEndElement(); // End of OtherParts
- SaveScriptedState(writer);
- writer.WriteEndElement(); // End of SceneObjectGroup
-
- //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
- }
-
public void SaveScriptedState(XmlTextWriter writer)
{
XmlDocument doc = new XmlDocument();
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 0ec1922..03a4289 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -129,13 +129,62 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
//m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
return sceneObject;
- }
+ }
///
- /// Deserialize a scene object from the 'xml2' format
+ /// Serialize a scene object to the original xml format
///
- ///
+ ///
///
+ public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
+ {
+ using (StringWriter sw = new StringWriter())
+ {
+ using (XmlTextWriter writer = new XmlTextWriter(sw))
+ {
+ ToOriginalXmlFormat(sceneObject, writer);
+ }
+
+ return sw.ToString();
+ }
+ }
+
+ ///
+ /// Serialize a scene object to the original xml format
+ ///
+ ///
+ ///
+ public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer)
+ {
+ //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
+ //int time = System.Environment.TickCount;
+
+ writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
+ writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
+ sceneObject.RootPart.ToXml(writer);
+ writer.WriteEndElement();
+ writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
+
+ lock (sceneObject.Children)
+ {
+ foreach (SceneObjectPart part in sceneObject.Children.Values)
+ {
+ if (part.UUID != sceneObject.RootPart.UUID)
+ {
+ writer.WriteStartElement(String.Empty, "Part", String.Empty);
+ part.ToXml(writer);
+ writer.WriteEndElement();
+ }
+ }
+ }
+
+ writer.WriteEndElement(); // OtherParts
+ sceneObject.SaveScriptedState(writer);
+ writer.WriteEndElement(); // SceneObjectGroup
+
+ //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
+ }
+
public static SceneObjectGroup FromXml2Format(string xmlData)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
@@ -193,40 +242,38 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
//m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
return sceneObject;
- }
+ }
///
- /// Serialize a scene object to the original xml format
+ /// Serialize a scene object to the 'xml2' format.
///
///
- ///
- public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
+ ///
+ public static string ToXml2Format(SceneObjectGroup sceneObject)
{
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
{
- ToOriginalXmlFormat(sceneObject, writer);
+ ToXml2Format(sceneObject, writer);
}
return sw.ToString();
}
- }
+ }
///
- /// Serialize a scene object to the original xml format
+ /// Serialize a scene object to the 'xml2' format.
///
///
- ///
- public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer)
+ ///
+ public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer)
{
- //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
+ //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name);
//int time = System.Environment.TickCount;
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
- writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
sceneObject.RootPart.ToXml(writer);
- writer.WriteEndElement();
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
lock (sceneObject.Children)
@@ -235,36 +282,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
{
if (part.UUID != sceneObject.RootPart.UUID)
{
- writer.WriteStartElement(String.Empty, "Part", String.Empty);
part.ToXml(writer);
- writer.WriteEndElement();
}
}
}
- writer.WriteEndElement(); // OtherParts
+ writer.WriteEndElement(); // End of OtherParts
sceneObject.SaveScriptedState(writer);
- writer.WriteEndElement(); // SceneObjectGroup
-
- //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
- }
-
- ///
- /// Serialize a scene object to the 'xml2' format.
- ///
- ///
- ///
- public static string ToXml2Format(ISceneObject sceneObject)
- {
- using (StringWriter sw = new StringWriter())
- {
- using (XmlTextWriter writer = new XmlTextWriter(sw))
- {
- sceneObject.ToXml2(writer);
- }
+ writer.WriteEndElement(); // End of SceneObjectGroup
- return sw.ToString();
- }
- }
+ //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
+ }
}
}
--
cgit v1.1