//Create an instance of the data node type that is mapped to the name of the xml DOM node public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) { IDataNode dataNode = null; try { if (preNode == null) { if (!m_Nodes.ContainsKey(node.Name)) { //throw new XmlException("Unknown XML node: " + node.Name); return(null); } NodeEntry ne = (NodeEntry)m_Nodes[node.Name]; Type type = ne.Type; DataNodeAttribute dna = ne.Attribute; dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); if (dataNode == null) { throw new OutOfMemoryException("Could not create new parser instance: " + type.FullName); } } else { dataNode = preNode; } dataNode.Parent = parent; dataNode.Parse(node); } catch (WarningException wex) { m_Log.Write(LogType.Warning, wex.Message); return(null); } catch (FatalException fex) { m_Log.WriteException(LogType.Error, fex); throw; } catch (Exception ex) { m_Log.WriteException(LogType.Error, ex); throw; } return(dataNode); }
private void CacheNodeTypes(Assembly assm) { foreach (Type t in assm.GetTypes()) { DataNodeAttribute dna = (DataNodeAttribute)Helper.CheckType(t, typeof(DataNodeAttribute), typeof(IDataNode)); if (dna == null) { continue; } NodeEntry ne = new NodeEntry(); ne.Type = t; ne.Attribute = dna; m_Nodes[dna.Name] = ne; } }