OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
/// <summary>
/// Populate a node with data read from xml using a dictinoary of processors
/// </summary>
/// <param name="nodeToFill"></param>
/// <param name="processors"></param>
/// <param name="xtr"></param>
/// <param name="parseExceptionAction">
/// Action to take if there is a parsing problem.  This will usually just be to log the exception
/// </param>
/// <returns>true on successful, false if there were any processing failures</returns>
Populate a node with data read from xml using a dictinoary of processors
Populate a node with data read from xml using a dictinoary of processors
public static bool ExecuteReadProcessors<NodeType>(
            NodeType nodeToFill,
            Dictionary<string, Action<NodeType, XmlReader>> processors,
            XmlReader xtr,
            Action<NodeType, string, Exception> parseExceptionAction)
        {
            bool errors = false;
            string nodeName = string.Empty;
            while (xtr.NodeType != XmlNodeType.EndElement)
            {
                nodeName = xtr.Name;
                Action<NodeType, XmlReader> p = null;
                if (processors.TryGetValue(xtr.Name, out p))
                {
                    try
                    {
                        p(nodeToFill, xtr);
                    }
                    catch (Exception e)
                    {
                        errors = true;
                        parseExceptionAction(nodeToFill, nodeName, e);
                        if (xtr.NodeType == XmlNodeType.EndElement)
                            xtr.Read();
                    }
                }
                else
                {
                    xtr.ReadOuterXml(); 
                }
            }
            return errors;
        }
public static bool ExecuteReadProcessors < NodeType > ( NodeType nodeToFill , Dictionary < string , Action < NodeType , XmlReader > > processors , XmlReader xtr , Action < NodeType , string , Exception > parseExceptionAction ) { bool errors = false ; string nodeName = string . Empty ; while ( xtr . NodeType != XmlNodeType . EndElement ) { nodeName = xtr . Name ; Action < NodeType , XmlReader > p = null ; if ( processors . TryGetValue ( xtr . Name , out p ) ) { try { p ( nodeToFill , xtr ) ; } catch ( Exception e ) { errors = true ; parseExceptionAction ( nodeToFill , nodeName , e ) ; if ( xtr . NodeType == XmlNodeType . EndElement ) xtr . Read ( ) ; } } else { xtr . ReadOuterXml ( ) ; } } return errors ; }
Populate a node with data read from xml using a dictinoary of processors
Populate a node with data read from xml using a dictinoary of processors
//                        m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); //                            m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); // ignore
true on successful, false if there were any processing failures
true on successful false if there were any processing failures
nodeToFill
NodeType
None
processors
Dictionary<string, Action<NodeType, XmlReader>>
None
xtr
XmlReader
None
parseExceptionAction
Action<NodeType, string, Exception>
Action to take if there is a parsing problem.  This will usually just be to log the exception
Action to take if there is a parsing problem . This will usually just be to log the exception