Exemple #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);
         }
     }
 }
Exemple #2
0
        public static SvgElement LoadFromXML(XmlDocument doc, XmlElement el)
        {
            if (el == null)
            {
                foreach (XmlNode xmlNode in doc.ChildNodes)
                {
                    if (xmlNode.GetType() == typeof(XmlElement))
                    {
                        el = (XmlElement)xmlNode;
                        break;
                    }
                }
            }
            SvgElement result;

            if (el == null)
            {
                result = null;
            }
            else
            {
                if (SvgFactory._elementNameDictionary == null)
                {
                    SvgFactory.BuildElementNameDictionary();
                }
                Type       type       = (Type)SvgFactory._elementNameDictionary[el.Name];
                SvgElement svgElement = (SvgElement)type.GetConstructor(new Type[0]).Invoke(new object[0]);
                SvgFactory.RecLoadFromXML(svgElement, doc, el);
                result = svgElement;
            }
            return(result);
        }