aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Serialization
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-05-08 18:05:54 +0000
committerJustin Clarke Casey2009-05-08 18:05:54 +0000
commit9f39a490b55580a25baf25db49cfaba8abd8e6b5 (patch)
tree4c16e1948290490111482a89e88c40e36ef12892 /OpenSim/Region/Framework/Scenes/Serialization
parent* minor: rename xml sog serialization method for readability (diff)
downloadopensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.zip
opensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.tar.gz
opensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.tar.bz2
opensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.tar.xz
* refactor: break out sog original xml serialization to a separate class
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization')
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs66
1 files changed, 60 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index ebb27c3..9eac3be 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
64 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 64 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
65 //int time = System.Environment.TickCount; 65 //int time = System.Environment.TickCount;
66 66
67 SceneObjectGroup so = new SceneObjectGroup(); 67 SceneObjectGroup sceneObject = new SceneObjectGroup();
68 68
69 // libomv.types changes UUID to Guid 69 // libomv.types changes UUID to Guid
70 serialization = serialization.Replace("<UUID>", "<Guid>"); 70 serialization = serialization.Replace("<UUID>", "<Guid>");
@@ -94,7 +94,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
94 { 94 {
95 sr = new StringReader(parts[0].InnerXml); 95 sr = new StringReader(parts[0].InnerXml);
96 reader = new XmlTextReader(sr); 96 reader = new XmlTextReader(sr);
97 so.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); 97 sceneObject.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader));
98 reader.Close(); 98 reader.Close();
99 sr.Close(); 99 sr.Close();
100 } 100 }
@@ -107,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
107 reader = new XmlTextReader(sr); 107 reader = new XmlTextReader(sr);
108 SceneObjectPart part = SceneObjectPart.FromXml(reader); 108 SceneObjectPart part = SceneObjectPart.FromXml(reader);
109 linkNum = part.LinkNum; 109 linkNum = part.LinkNum;
110 so.AddPart(part); 110 sceneObject.AddPart(part);
111 part.LinkNum = linkNum; 111 part.LinkNum = linkNum;
112 part.TrimPermissions(); 112 part.TrimPermissions();
113 part.StoreUndoState(); 113 part.StoreUndoState();
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
117 117
118 // Script state may, or may not, exist. Not having any, is NOT 118 // Script state may, or may not, exist. Not having any, is NOT
119 // ever a problem. 119 // ever a problem.
120 so.LoadScriptState(doc); 120 sceneObject.LoadScriptState(doc);
121 } 121 }
122 catch (Exception e) 122 catch (Exception e)
123 { 123 {
@@ -127,7 +127,61 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
127 127
128 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); 128 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
129 129
130 return so; 130 return sceneObject;
131 } 131 }
132
133 /// <summary>
134 /// Serialize a scene object to the original xml format
135 /// </summary>
136 /// <param name="sceneObject"></param>
137 /// <returns></returns>
138 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
139 {
140 using (StringWriter sw = new StringWriter())
141 {
142 using (XmlTextWriter writer = new XmlTextWriter(sw))
143 {
144 ToOriginalXmlFormat(sceneObject, writer);
145 }
146
147 return sw.ToString();
148 }
149 }
150
151 /// <summary>
152 /// Serialize a scene object to the original xml format
153 /// </summary>
154 /// <param name="sceneObject"></param>
155 /// <returns></returns>
156 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer)
157 {
158 //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
159 //int time = System.Environment.TickCount;
160
161 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
162 writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
163 sceneObject.RootPart.ToXml(writer);
164 writer.WriteEndElement();
165 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
166
167 lock (sceneObject.Children)
168 {
169 foreach (SceneObjectPart part in sceneObject.Children.Values)
170 {
171 if (part.UUID != sceneObject.RootPart.UUID)
172 {
173 writer.WriteStartElement(String.Empty, "Part", String.Empty);
174 part.ToXml(writer);
175 writer.WriteEndElement();
176 }
177 }
178 }
179
180 writer.WriteEndElement(); // OtherParts
181 sceneObject.SaveScriptedState(writer);
182 writer.WriteEndElement(); // SceneObjectGroup
183
184 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
185 }
132 } 186 }
133} 187}