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
---
.../Scenes/Serialization/SceneObjectSerializer.cs | 105 +++++++++++++--------
1 file changed, 66 insertions(+), 39 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/Serialization')
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