示例#1
0
 private static void RecLoadFromXML(SvgElement e, XmlDocument doc, XmlElement el)
 {
     e.ReadXmlElement(doc, el);
     foreach (XmlNode xmlNode in el.ChildNodes)
     {
         if (xmlNode.GetType() == typeof(XmlElement))
         {
             XmlElement xmlElement = (XmlElement)xmlNode;
             Type       type       = (Type)SvgFactory._elementNameDictionary[xmlElement.Name];
             SvgElement svgElement;
             if (type == null)
             {
                 svgElement = new SvgGenericElement(xmlElement.Name);
             }
             else
             {
                 svgElement = (SvgElement)type.GetConstructor(new Type[0]).Invoke(new object[0]);
             }
             e.AddChild(svgElement);
             SvgFactory.RecLoadFromXML(svgElement, doc, xmlElement);
         }
         else if (xmlNode.GetType() == typeof(XmlText))
         {
             XmlText  xmlText = (XmlText)xmlNode;
             TextNode ch      = new TextNode(xmlText.InnerText);
             e.AddChild(ch);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Used by LoadFromXML
        /// </summary>
        /// <param name="e"></param>
        /// <param name="doc"></param>
        /// <param name="el"></param>
        private static void RecLoadFromXML(SvgElement e, XmlDocument doc, XmlElement el)
        {
            e.ReadXmlElement(doc, el);

            foreach (XmlNode noddo in el.ChildNodes)
            {
                if (noddo.GetType() == typeof(XmlElement))
                {
                    var childXml = (XmlElement)noddo;

                    var t = (Type)_elementNameDictionary[childXml.Name];

                    SvgElement childSvg = null;

                    if (t == null)
                    {
                        childSvg = new SvgGenericElement(childXml.Name);
                    }
                    else
                    {
                        childSvg = (SvgElement)t.GetConstructor(new Type[0]).Invoke(new object[0]);
                    }

                    e.AddChild(childSvg);

                    RecLoadFromXML(childSvg, doc, childXml);
                }
                else if (noddo.GetType() == typeof(XmlText))
                {
                    var xt = (XmlText)noddo;

                    var tn = new TextNode(xt.InnerText);

                    e.AddChild(tn);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Used by LoadFromXML
        /// </summary>
        /// <param name="e"></param>
        /// <param name="doc"></param>
        /// <param name="el"></param>
        private static void RecLoadFromXML(SvgElement e, XmlDocument doc, XmlElement el)
        {
            e.ReadXmlElement(doc, el);

            foreach(XmlNode noddo in el.ChildNodes)
            {
                if (noddo.GetType() == typeof(XmlElement))
                {
                    XmlElement childXml = (XmlElement)noddo;

                    Type t = (Type)_elementNameDictionary[childXml.Name];

                    SvgElement childSvg=null;

                    if (t == null)
                    {
                        childSvg = new SvgGenericElement(childXml.Name);
                    }
                    else
                    {
                        childSvg = (SvgElement)t.GetConstructor(new System.Type[0]).Invoke(new object[0]);
                    }

                    e.AddChild(childSvg);

                    RecLoadFromXML(childSvg, doc, childXml);
                }
                else if (noddo.GetType() == typeof(XmlText))
                {
                    XmlText xt = (XmlText)noddo;

                    TextNode tn = new TextNode(xt.InnerText);

                    e.AddChild(tn);
                }
            }
        }