From 623426421132fdc41d9de006fb55aedc660d5362 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Feb 2012 22:45:50 +0000 Subject: Refactor common deserialization processor code to generic method ExternalRepresentationUtils.ExecuteReadProcessors() --- .../Serialization/External/LandDataSerializer.cs | 74 ++-------------------- 1 file changed, 6 insertions(+), 68 deletions(-) (limited to 'OpenSim/Framework/Serialization/External/LandDataSerializer.cs') 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 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); - private delegate void LandDataProcessor(LandData landData, XmlTextReader reader); - private static Dictionary m_ldProcessors - = new Dictionary(); + private static Dictionary> m_ldProcessors + = new Dictionary>(); - private delegate void LandAccessEntryProcessor(LandAccessEntry lae, XmlTextReader reader); - private static Dictionary m_laeProcessors - = new Dictionary(); + private static Dictionary> m_laeProcessors + = new Dictionary>(); static LandDataSerializer() { @@ -146,38 +144,7 @@ namespace OpenSim.Framework.Serialization.External xtr.ReadStartElement("ParcelAccessEntry"); - string nodeName = string.Empty; - while (xtr.NodeType != XmlNodeType.EndElement) - { - nodeName = xtr.Name; - -// m_log.DebugFormat("[LandDataSerializer]: Processing: {0} in ParcelAccessEntry", nodeName); - - LandAccessEntryProcessor p = null; - if (m_laeProcessors.TryGetValue(xtr.Name, out p)) - { -// m_log.DebugFormat("[LandDataSerializer]: Found {0} processor in ParcelAccessEntry", nodeName); - - try - { - p(lae, xtr); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LandDataSerializer]: Exception while parsing element {0} in ParcelAccessEntry, continuing. Exception {1}{2}", - nodeName, e.Message, e.StackTrace); - - if (xtr.NodeType == XmlNodeType.EndElement) - xtr.Read(); - } - } - else - { - // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); - xtr.ReadOuterXml(); // ignore - } - } + ExternalRepresentationUtils.ExecuteReadProcessors(lae, m_laeProcessors, xtr); xtr.ReadEndElement(); @@ -213,36 +180,7 @@ namespace OpenSim.Framework.Serialization.External { reader.ReadStartElement("LandData"); - string nodeName = string.Empty; - while (reader.NodeType != XmlNodeType.EndElement) - { - nodeName = reader.Name; - -// m_log.DebugFormat("[LandDataSerializer]: Processing: {0}", nodeName); - - LandDataProcessor p = null; - if (m_ldProcessors.TryGetValue(reader.Name, out p)) - { - try - { - p(landData, reader); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LandDataSerializer]: exception while parsing element {0}, continuing. Exception {1}{2}", - nodeName, e.Message, e.StackTrace); - - if (reader.NodeType == XmlNodeType.EndElement) - reader.Read(); - } - } - else - { - // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); - reader.ReadOuterXml(); // ignore - } - } + ExternalRepresentationUtils.ExecuteReadProcessors(landData, m_ldProcessors, reader); reader.ReadEndElement(); } -- cgit v1.1