diff options
author | Justin Clark-Casey (justincc) | 2012-02-03 22:45:50 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-02-03 22:45:50 +0000 |
commit | 623426421132fdc41d9de006fb55aedc660d5362 (patch) | |
tree | 822320d0b9108cb201ca5c2bcfd15f30c929862a /OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |
parent | Change LandDataSerializer deserialization so that in the future it won't care... (diff) | |
download | opensim-SC-623426421132fdc41d9de006fb55aedc660d5362.zip opensim-SC-623426421132fdc41d9de006fb55aedc660d5362.tar.gz opensim-SC-623426421132fdc41d9de006fb55aedc660d5362.tar.bz2 opensim-SC-623426421132fdc41d9de006fb55aedc660d5362.tar.xz |
Refactor common deserialization processor code to generic method ExternalRepresentationUtils.ExecuteReadProcessors()
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Serialization/External/LandDataSerializer.cs | 74 |
1 files changed, 6 insertions, 68 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index bf6c4e5..a12877a 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |||
@@ -46,13 +46,11 @@ namespace OpenSim.Framework.Serialization.External | |||
46 | 46 | ||
47 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); | 47 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); |
48 | 48 | ||
49 | private delegate void LandDataProcessor(LandData landData, XmlTextReader reader); | 49 | private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors |
50 | private static Dictionary<string, LandDataProcessor> m_ldProcessors | 50 | = new Dictionary<string, Action<LandData, XmlTextReader>>(); |
51 | = new Dictionary<string, LandDataProcessor>(); | ||
52 | 51 | ||
53 | private delegate void LandAccessEntryProcessor(LandAccessEntry lae, XmlTextReader reader); | 52 | private static Dictionary<string, Action<LandAccessEntry, XmlTextReader>> m_laeProcessors |
54 | private static Dictionary<string, LandAccessEntryProcessor> m_laeProcessors | 53 | = new Dictionary<string, Action<LandAccessEntry, XmlTextReader>>(); |
55 | = new Dictionary<string, LandAccessEntryProcessor>(); | ||
56 | 54 | ||
57 | static LandDataSerializer() | 55 | static LandDataSerializer() |
58 | { | 56 | { |
@@ -146,38 +144,7 @@ namespace OpenSim.Framework.Serialization.External | |||
146 | 144 | ||
147 | xtr.ReadStartElement("ParcelAccessEntry"); | 145 | xtr.ReadStartElement("ParcelAccessEntry"); |
148 | 146 | ||
149 | string nodeName = string.Empty; | 147 | ExternalRepresentationUtils.ExecuteReadProcessors<LandAccessEntry>(lae, m_laeProcessors, xtr); |
150 | while (xtr.NodeType != XmlNodeType.EndElement) | ||
151 | { | ||
152 | nodeName = xtr.Name; | ||
153 | |||
154 | // m_log.DebugFormat("[LandDataSerializer]: Processing: {0} in ParcelAccessEntry", nodeName); | ||
155 | |||
156 | LandAccessEntryProcessor p = null; | ||
157 | if (m_laeProcessors.TryGetValue(xtr.Name, out p)) | ||
158 | { | ||
159 | // m_log.DebugFormat("[LandDataSerializer]: Found {0} processor in ParcelAccessEntry", nodeName); | ||
160 | |||
161 | try | ||
162 | { | ||
163 | p(lae, xtr); | ||
164 | } | ||
165 | catch (Exception e) | ||
166 | { | ||
167 | m_log.ErrorFormat( | ||
168 | "[LandDataSerializer]: Exception while parsing element {0} in ParcelAccessEntry, continuing. Exception {1}{2}", | ||
169 | nodeName, e.Message, e.StackTrace); | ||
170 | |||
171 | if (xtr.NodeType == XmlNodeType.EndElement) | ||
172 | xtr.Read(); | ||
173 | } | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); | ||
178 | xtr.ReadOuterXml(); // ignore | ||
179 | } | ||
180 | } | ||
181 | 148 | ||
182 | xtr.ReadEndElement(); | 149 | xtr.ReadEndElement(); |
183 | 150 | ||
@@ -213,36 +180,7 @@ namespace OpenSim.Framework.Serialization.External | |||
213 | { | 180 | { |
214 | reader.ReadStartElement("LandData"); | 181 | reader.ReadStartElement("LandData"); |
215 | 182 | ||
216 | string nodeName = string.Empty; | 183 | ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader); |
217 | while (reader.NodeType != XmlNodeType.EndElement) | ||
218 | { | ||
219 | nodeName = reader.Name; | ||
220 | |||
221 | // m_log.DebugFormat("[LandDataSerializer]: Processing: {0}", nodeName); | ||
222 | |||
223 | LandDataProcessor p = null; | ||
224 | if (m_ldProcessors.TryGetValue(reader.Name, out p)) | ||
225 | { | ||
226 | try | ||
227 | { | ||
228 | p(landData, reader); | ||
229 | } | ||
230 | catch (Exception e) | ||
231 | { | ||
232 | m_log.ErrorFormat( | ||
233 | "[LandDataSerializer]: exception while parsing element {0}, continuing. Exception {1}{2}", | ||
234 | nodeName, e.Message, e.StackTrace); | ||
235 | |||
236 | if (reader.NodeType == XmlNodeType.EndElement) | ||
237 | reader.Read(); | ||
238 | } | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); | ||
243 | reader.ReadOuterXml(); // ignore | ||
244 | } | ||
245 | } | ||
246 | 184 | ||
247 | reader.ReadEndElement(); | 185 | reader.ReadEndElement(); |
248 | } | 186 | } |