aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs53
1 files changed, 52 insertions, 1 deletions
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
index 7447ac2..39a9f37 100644
--- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -24,11 +24,13 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System; 28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.IO; 30using System.IO;
31using System.Reflection;
30using System.Xml; 32using System.Xml;
31 33using log4net;
32using OpenMetaverse; 34using OpenMetaverse;
33using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
34 36
@@ -39,6 +41,55 @@ namespace OpenSim.Framework.Serialization.External
39 /// </summary> 41 /// </summary>
40 public class ExternalRepresentationUtils 42 public class ExternalRepresentationUtils
41 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 /// <summary>
47 /// Populate a node with data read from xml using a dictinoary of processors
48 /// </summary>
49 /// <param name="nodeToFill"></param>
50 /// <param name="processors">
51 /// A <see cref="Dictionary<System.String, Action<NodeType, XmlTextReader>>"/>
52 /// </param>
53 /// <param name="xtr">
54 /// A <see cref="XmlTextReader"/>
55 /// </param>
56 public static void ExecuteReadProcessors<NodeType>(
57 NodeType nodeToFill, Dictionary<string, Action<NodeType, XmlTextReader>> processors, XmlTextReader xtr)
58 {
59 string nodeName = string.Empty;
60 while (xtr.NodeType != XmlNodeType.EndElement)
61 {
62 nodeName = xtr.Name;
63
64// m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName);
65
66 Action<NodeType, XmlTextReader> p = null;
67 if (processors.TryGetValue(xtr.Name, out p))
68 {
69// m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName);
70
71 try
72 {
73 p(nodeToFill, xtr);
74 }
75 catch (Exception e)
76 {
77 m_log.ErrorFormat(
78 "[ExternalRepresentationUtils]: Exception while parsing element {0}, continuing. Exception {1}{2}",
79 nodeName, e.Message, e.StackTrace);
80
81 if (xtr.NodeType == XmlNodeType.EndElement)
82 xtr.Read();
83 }
84 }
85 else
86 {
87 // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName);
88 xtr.ReadOuterXml(); // ignore
89 }
90 }
91 }
92
42 /// <summary> 93 /// <summary>
43 /// Takes a XML representation of a SceneObjectPart and returns another XML representation 94 /// Takes a XML representation of a SceneObjectPart and returns another XML representation
44 /// with creator data added to it. 95 /// with creator data added to it.