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.cs40
1 files changed, 7 insertions, 33 deletions
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index f138437..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)
@@ -305,14 +279,14 @@ namespace OpenSim.Framework.Serialization.External
305 writer.WriteEndElement(); 279 writer.WriteEndElement();
306 if (options.ContainsKey("creators") && inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty) 280 if (options.ContainsKey("creators") && inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty)
307 writer.WriteElementString("CreatorData", inventoryItem.CreatorData); 281 writer.WriteElementString("CreatorData", inventoryItem.CreatorData);
308 else if (options.ContainsKey("profile")) 282 else if (options.ContainsKey("home"))
309 { 283 {
310 if (userAccountService != null) 284 if (userAccountService != null)
311 { 285 {
312 UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid); 286 UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid);
313 if (account != null) 287 if (account != null)
314 { 288 {
315 writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName); 289 writer.WriteElementString("CreatorData", (string)options["home"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName);
316 } 290 }
317 writer.WriteElementString("CreatorID", inventoryItem.CreatorId); 291 writer.WriteElementString("CreatorID", inventoryItem.CreatorId);
318 } 292 }