aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-03 22:45:50 +0000
committerJustin Clark-Casey (justincc)2012-02-03 22:45:50 +0000
commit623426421132fdc41d9de006fb55aedc660d5362 (patch)
tree822320d0b9108cb201ca5c2bcfd15f30c929862a /OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
parentChange LandDataSerializer deserialization so that in the future it won't care... (diff)
downloadopensim-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 'OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs')
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs33
1 files changed, 4 insertions, 29 deletions
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
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader); 49 private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors
50 private static Dictionary<string, InventoryItemXmlProcessor> m_InventoryItemXmlProcessors = new Dictionary<string, InventoryItemXmlProcessor>(); 50 = new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>();
51 51
52 #region InventoryItemBase Processor initialization 52 #region InventoryItemBase Processor initialization
53 static UserInventoryItemSerializer() 53 static UserInventoryItemSerializer()
@@ -204,39 +204,14 @@ namespace OpenSim.Framework.Serialization.External
204 { 204 {
205 reader.ReadStartElement("InventoryItem"); 205 reader.ReadStartElement("InventoryItem");
206 206
207 string nodeName = string.Empty; 207 ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>(
208 while (reader.NodeType != XmlNodeType.EndElement) 208 item, m_InventoryItemXmlProcessors, reader);
209 {
210 nodeName = reader.Name;
211 InventoryItemXmlProcessor p = null;
212 if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p))
213 {
214 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
215 try
216 {
217 p(item, reader);
218 }
219 catch (Exception e)
220 {
221 m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e);
222 if (reader.NodeType == XmlNodeType.EndElement)
223 reader.Read();
224 }
225 }
226 else
227 {
228 // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName);
229 reader.ReadOuterXml(); // ignore
230 }
231
232 }
233 209
234 reader.ReadEndElement(); // InventoryItem 210 reader.ReadEndElement(); // InventoryItem
235 } 211 }
236 212
237 //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); 213 //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID);
238 return item; 214 return item;
239
240 } 215 }
241 216
242 public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService) 217 public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService)