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() --- .../External/UserInventoryItemSerializer.cs | 33 +++------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs') diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index 5d986d5..f6fdc4b 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs @@ -46,8 +46,8 @@ namespace OpenSim.Framework.Serialization.External { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader); - private static Dictionary m_InventoryItemXmlProcessors = new Dictionary(); + private static Dictionary> m_InventoryItemXmlProcessors + = new Dictionary>(); #region InventoryItemBase Processor initialization static UserInventoryItemSerializer() @@ -204,39 +204,14 @@ namespace OpenSim.Framework.Serialization.External { reader.ReadStartElement("InventoryItem"); - string nodeName = string.Empty; - while (reader.NodeType != XmlNodeType.EndElement) - { - nodeName = reader.Name; - InventoryItemXmlProcessor p = null; - if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p)) - { - //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name); - try - { - p(item, reader); - } - catch (Exception e) - { - m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e); - if (reader.NodeType == XmlNodeType.EndElement) - reader.Read(); - } - } - else - { - // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName); - reader.ReadOuterXml(); // ignore - } - - } + ExternalRepresentationUtils.ExecuteReadProcessors( + item, m_InventoryItemXmlProcessors, reader); reader.ReadEndElement(); // InventoryItem } //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); return item; - } public static string Serialize(InventoryItemBase inventoryItem, Dictionary options, IUserAccountService userAccountService) -- cgit v1.1