aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs36
1 files changed, 5 insertions, 31 deletions
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index b351703..57da7ca 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -41,14 +41,13 @@ namespace OpenSim.Framework.Serialization.External
41{ 41{
42 /// <summary> 42 /// <summary>
43 /// Serialize and deserialize user inventory items as an external format. 43 /// Serialize and deserialize user inventory items as an external format.
44 /// </summary> 44 /// </summary>
45 /// XXX: Please do not use yet.
46 public class UserInventoryItemSerializer 45 public class UserInventoryItemSerializer
47 { 46 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 48
50 private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader); 49 private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors
51 private static Dictionary<string, InventoryItemXmlProcessor> m_InventoryItemXmlProcessors = new Dictionary<string, InventoryItemXmlProcessor>(); 50 = new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>();
52 51
53 #region InventoryItemBase Processor initialization 52 #region InventoryItemBase Processor initialization
54 static UserInventoryItemSerializer() 53 static UserInventoryItemSerializer()
@@ -205,39 +204,14 @@ namespace OpenSim.Framework.Serialization.External
205 { 204 {
206 reader.ReadStartElement("InventoryItem"); 205 reader.ReadStartElement("InventoryItem");
207 206
208 string nodeName = string.Empty; 207 ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>(
209 while (reader.NodeType != XmlNodeType.EndElement) 208 item, m_InventoryItemXmlProcessors, reader);
210 {
211 nodeName = reader.Name;
212 InventoryItemXmlProcessor p = null;
213 if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p))
214 {
215 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
216 try
217 {
218 p(item, reader);
219 }
220 catch (Exception e)
221 {
222 m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e);
223 if (reader.NodeType == XmlNodeType.EndElement)
224 reader.Read();
225 }
226 }
227 else
228 {
229 // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName);
230 reader.ReadOuterXml(); // ignore
231 }
232
233 }
234 209
235 reader.ReadEndElement(); // InventoryItem 210 reader.ReadEndElement(); // InventoryItem
236 } 211 }
237 212
238 //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);
239 return item; 214 return item;
240
241 } 215 }
242 216
243 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)