aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs47
1 files changed, 41 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
index a0e120a..babcb54 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
@@ -55,11 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
55 /// <param name="coa"></param> 55 /// <param name="coa"></param>
56 /// <returns></returns> 56 /// <returns></returns>
57 public static string ToXml(CoalescedSceneObjects coa) 57 public static string ToXml(CoalescedSceneObjects coa)
58 { 58 {
59 // TODO: Should probably return an empty xml serialization rather than a blank string
60 if (!coa.HasObjects)
61 return "";
62
63 using (StringWriter sw = new StringWriter()) 59 using (StringWriter sw = new StringWriter())
64 { 60 {
65 using (XmlTextWriter writer = new XmlTextWriter(sw)) 61 using (XmlTextWriter writer = new XmlTextWriter(sw))
@@ -105,10 +101,49 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
105 101
106 string output = sw.ToString(); 102 string output = sw.ToString();
107 103
108// m_log.Debug(output); 104// Console.WriteLine(output);
109 105
110 return output; 106 return output;
111 } 107 }
112 } 108 }
109
110 public static bool TryFromXml(string xml, out CoalescedSceneObjects coa)
111 {
112// m_log.DebugFormat("[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() deserializing {0}", xml);
113
114 coa = null;
115
116 using (StringReader sr = new StringReader(xml))
117 {
118 using (XmlTextReader reader = new XmlTextReader(sr))
119 {
120 reader.Read();
121 if (reader.Name != "CoalescedObject")
122 {
123// m_log.DebugFormat(
124// "[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() root element was {0} so returning false",
125// reader.Name);
126
127 return false;
128 }
129
130 coa = new CoalescedSceneObjects(UUID.Zero);
131 reader.Read();
132
133 while (reader.NodeType != XmlNodeType.EndElement && reader.Name != "CoalescedObject")
134 {
135 if (reader.Name == "SceneObjectGroup")
136 {
137 string soXml = reader.ReadOuterXml();
138 coa.Add(SceneObjectSerializer.FromOriginalXmlFormat(soXml));
139 }
140 }
141
142 reader.ReadEndElement(); // CoalescedObject
143 }
144 }
145
146 return true;
147 }
113 } 148 }
114} \ No newline at end of file 149} \ No newline at end of file