Exemple #1
0
        public static GeneratorElement ParseFromXml(Configuration options, XmlDocument doc, ParserValidationDelegate vd)
        {
            GeneratorElement generator = new GeneratorElement();
            XmlNodeList      elements  = doc.DocumentElement.GetElementsByTagName("generator");

            if (elements.Count == 0)
            {
                generator.Class = "Spring2.DataTierGenerator.Generator.CodeGenerator,Spring2.DataTierGenerator";
            }
            else
            {
                generator.Class = elements[0].Attributes["class"].Value;
                generator.Tasks = TaskElement.ParseFromXml(options, elements[0], vd);
                generator.Tools = ToolElement.ParseFromXml(options, elements[0], vd);
                foreach (XmlNode node in GetChildNodes(elements[0], WriterElement.WRITER))
                {
                    generator.Writers.Add(new WriterElement(node));
                }
                foreach (XmlNode node in GetChildNodes(elements[0], StylerElement.STYLER))
                {
                    generator.Stylers.Add(new StylerElement(node));
                }
            }
            return(generator);
        }
Exemple #2
0
        /// <summary>
        /// Parse only method. Parses and adds all entities found in the given node and adds them to the given
        /// list.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="generatorElements"></param>
        public static void ParseFromXml(XmlNode node, IList generatorElements)
        {
            if (node != null && generatorElements != null)
            {
                foreach (XmlNode generatorNode in node.ChildNodes)
                {
                    if (generatorNode.NodeType.Equals(XmlNodeType.Element))
                    {
                        GeneratorElement generatorElement = new GeneratorElement();

                        generatorElement.Class = GetAttributeValue(generatorNode, CLASS, generatorElement.Class);
                        TaskElement.ParseFromXml(generatorNode, generatorElement.Tasks);
                        ToolElement.ParseFromXml(generatorNode, generatorElement.Tools);
                        foreach (XmlNode writer in GetChildNodes(generatorNode, WriterElement.WRITER))
                        {
                            generatorElement.Writers.Add(new WriterElement(writer));
                        }
                        foreach (XmlNode styler in GetChildNodes(generatorNode, StylerElement.STYLER))
                        {
                            generatorElement.Stylers.Add(new StylerElement(styler));
                        }

                        generatorElements.Add(generatorElement);
                    }
                }
            }
        }