diff options
author | Justin Clarke Casey | 2009-05-14 18:08:54 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-05-14 18:08:54 +0000 |
commit | 303aa4b65ead33c44122d61c0f9ef075236e6f76 (patch) | |
tree | 9007de8773b2f33af81ec2530214ecb3ef468db6 /OpenSim/Region/Framework/Scenes | |
parent | * refactor: break some of xml2 serialization out of sog (diff) | |
download | opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.zip opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.tar.gz opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.tar.bz2 opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.tar.xz |
* refactor: move bottom part of 'xml2' serializaton to separate class
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 27 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 105 |
2 files changed, 66 insertions, 66 deletions
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 | |||
583 | 583 | ||
584 | #endregion | 584 | #endregion |
585 | 585 | ||
586 | public void ToXml2(XmlTextWriter writer) | ||
587 | { | ||
588 | //m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name); | ||
589 | //int time = System.Environment.TickCount; | ||
590 | |||
591 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
592 | m_rootPart.ToXml(writer); | ||
593 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
594 | |||
595 | lock (m_parts) | ||
596 | { | ||
597 | foreach (SceneObjectPart part in m_parts.Values) | ||
598 | { | ||
599 | if (part.UUID != m_rootPart.UUID) | ||
600 | { | ||
601 | part.ToXml(writer); | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | |||
606 | writer.WriteEndElement(); // End of OtherParts | ||
607 | SaveScriptedState(writer); | ||
608 | writer.WriteEndElement(); // End of SceneObjectGroup | ||
609 | |||
610 | //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); | ||
611 | } | ||
612 | |||
613 | public void SaveScriptedState(XmlTextWriter writer) | 586 | public void SaveScriptedState(XmlTextWriter writer) |
614 | { | 587 | { |
615 | XmlDocument doc = new XmlDocument(); | 588 | 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 | |||
129 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | 129 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); |
130 | 130 | ||
131 | return sceneObject; | 131 | return sceneObject; |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Deserialize a scene object from the 'xml2' format | 135 | /// Serialize a scene object to the original xml format |
136 | /// </summary> | 136 | /// </summary> |
137 | /// <param name="serialization"></param> | 137 | /// <param name="sceneObject"></param> |
138 | /// <returns></returns> | 138 | /// <returns></returns> |
139 | public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) | ||
140 | { | ||
141 | using (StringWriter sw = new StringWriter()) | ||
142 | { | ||
143 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | ||
144 | { | ||
145 | ToOriginalXmlFormat(sceneObject, writer); | ||
146 | } | ||
147 | |||
148 | return sw.ToString(); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | /// <summary> | ||
153 | /// Serialize a scene object to the original xml format | ||
154 | /// </summary> | ||
155 | /// <param name="sceneObject"></param> | ||
156 | /// <returns></returns> | ||
157 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) | ||
158 | { | ||
159 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); | ||
160 | //int time = System.Environment.TickCount; | ||
161 | |||
162 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
163 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); | ||
164 | sceneObject.RootPart.ToXml(writer); | ||
165 | writer.WriteEndElement(); | ||
166 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
167 | |||
168 | lock (sceneObject.Children) | ||
169 | { | ||
170 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
171 | { | ||
172 | if (part.UUID != sceneObject.RootPart.UUID) | ||
173 | { | ||
174 | writer.WriteStartElement(String.Empty, "Part", String.Empty); | ||
175 | part.ToXml(writer); | ||
176 | writer.WriteEndElement(); | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | |||
181 | writer.WriteEndElement(); // OtherParts | ||
182 | sceneObject.SaveScriptedState(writer); | ||
183 | writer.WriteEndElement(); // SceneObjectGroup | ||
184 | |||
185 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
186 | } | ||
187 | |||
139 | public static SceneObjectGroup FromXml2Format(string xmlData) | 188 | public static SceneObjectGroup FromXml2Format(string xmlData) |
140 | { | 189 | { |
141 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | 190 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); |
@@ -193,40 +242,38 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
193 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | 242 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); |
194 | 243 | ||
195 | return sceneObject; | 244 | return sceneObject; |
196 | } | 245 | } |
197 | 246 | ||
198 | /// <summary> | 247 | /// <summary> |
199 | /// Serialize a scene object to the original xml format | 248 | /// Serialize a scene object to the 'xml2' format. |
200 | /// </summary> | 249 | /// </summary> |
201 | /// <param name="sceneObject"></param> | 250 | /// <param name="sceneObject"></param> |
202 | /// <returns></returns> | 251 | /// <returns></returns> |
203 | public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) | 252 | public static string ToXml2Format(SceneObjectGroup sceneObject) |
204 | { | 253 | { |
205 | using (StringWriter sw = new StringWriter()) | 254 | using (StringWriter sw = new StringWriter()) |
206 | { | 255 | { |
207 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | 256 | using (XmlTextWriter writer = new XmlTextWriter(sw)) |
208 | { | 257 | { |
209 | ToOriginalXmlFormat(sceneObject, writer); | 258 | ToXml2Format(sceneObject, writer); |
210 | } | 259 | } |
211 | 260 | ||
212 | return sw.ToString(); | 261 | return sw.ToString(); |
213 | } | 262 | } |
214 | } | 263 | } |
215 | 264 | ||
216 | /// <summary> | 265 | /// <summary> |
217 | /// Serialize a scene object to the original xml format | 266 | /// Serialize a scene object to the 'xml2' format. |
218 | /// </summary> | 267 | /// </summary> |
219 | /// <param name="sceneObject"></param> | 268 | /// <param name="sceneObject"></param> |
220 | /// <returns></returns> | 269 | /// <returns></returns> |
221 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) | 270 | public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) |
222 | { | 271 | { |
223 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); | 272 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); |
224 | //int time = System.Environment.TickCount; | 273 | //int time = System.Environment.TickCount; |
225 | 274 | ||
226 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 275 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); |
227 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); | ||
228 | sceneObject.RootPart.ToXml(writer); | 276 | sceneObject.RootPart.ToXml(writer); |
229 | writer.WriteEndElement(); | ||
230 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | 277 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); |
231 | 278 | ||
232 | lock (sceneObject.Children) | 279 | lock (sceneObject.Children) |
@@ -235,36 +282,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
235 | { | 282 | { |
236 | if (part.UUID != sceneObject.RootPart.UUID) | 283 | if (part.UUID != sceneObject.RootPart.UUID) |
237 | { | 284 | { |
238 | writer.WriteStartElement(String.Empty, "Part", String.Empty); | ||
239 | part.ToXml(writer); | 285 | part.ToXml(writer); |
240 | writer.WriteEndElement(); | ||
241 | } | 286 | } |
242 | } | 287 | } |
243 | } | 288 | } |
244 | 289 | ||
245 | writer.WriteEndElement(); // OtherParts | 290 | writer.WriteEndElement(); // End of OtherParts |
246 | sceneObject.SaveScriptedState(writer); | 291 | sceneObject.SaveScriptedState(writer); |
247 | writer.WriteEndElement(); // SceneObjectGroup | 292 | writer.WriteEndElement(); // End of SceneObjectGroup |
248 | |||
249 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
250 | } | ||
251 | |||
252 | /// <summary> | ||
253 | /// Serialize a scene object to the 'xml2' format. | ||
254 | /// </summary> | ||
255 | /// <param name="sceneObject"></param> | ||
256 | /// <returns></returns> | ||
257 | public static string ToXml2Format(ISceneObject sceneObject) | ||
258 | { | ||
259 | using (StringWriter sw = new StringWriter()) | ||
260 | { | ||
261 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | ||
262 | { | ||
263 | sceneObject.ToXml2(writer); | ||
264 | } | ||
265 | 293 | ||
266 | return sw.ToString(); | 294 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); |
267 | } | 295 | } |
268 | } | ||
269 | } | 296 | } |
270 | } | 297 | } |