Exemple #1
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="taskElements"></param>
        public static void ParseFromXml(XmlNode node, IList taskElements)
        {
            if (node != null && taskElements != null)
            {
                XmlNodeList nodes = node.SelectNodes("tasks/task");
                foreach (XmlNode taskNode in nodes)
                {
                    if (node.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    TaskElement taskElement = new TaskElement();

                    taskElement.Name            = GetAttributeValue(taskNode, NAME, taskElement.Name);
                    taskElement.Template        = GetAttributeValue(taskNode, TEMPLATE, taskElement.Template);
                    taskElement.Element         = GetAttributeValue(taskNode, ELEMENT, taskElement.Element);
                    taskElement.Directory       = GetAttributeValue(taskNode, DIRECTORY, taskElement.Directory);
                    taskElement.FileNameFormat  = GetAttributeValue(taskNode, FILENAME_FORMAT, taskElement.FileNameFormat);
                    taskElement.Writer          = GetAttributeValue(taskNode, WRITER, taskElement.Writer);
                    taskElement.Styler          = GetAttributeValue(taskNode, STYLER, taskElement.Styler);
                    taskElement.BackupDirectory = GetAttributeValue(taskNode, BACKUP_DIRECTORY, taskElement.BackupDirectory);

                    taskElements.Add(taskElement);
                }
            }
        }
Exemple #2
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 #3
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);
                    }
                }
            }
        }
Exemple #4
0
        public static ArrayList ParseFromXml(Configuration options, XmlNode root, ParserValidationDelegate vd)
        {
            ArrayList   list  = new ArrayList();
            XmlNodeList nodes = root.SelectNodes("tasks/task");

            foreach (XmlNode node in nodes)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                TaskElement task = new TaskElement();
                task.Name           = node.Attributes["name"].Value;
                task.Element        = node.Attributes["element"].Value;
                task.Template       = node.Attributes["template"].Value;
                task.Directory      = node.Attributes["directory"].Value;
                task.FileNameFormat = node.Attributes["filenameformat"].Value;
                if (node.Attributes[BACKUP_DIRECTORY] != null)
                {
                    task.BackupDirectory = node.Attributes["backupdirectory"].Value;
                }
                else
                {
                    task.BackupDirectory = task.Directory;
                }
                if (!node.InnerText.Equals(String.Empty))
                {
                    task.Description = node.InnerText;
                }
                task.Includes   = IncludeElement.ParseFromXml(options, node, vd);
                task.Excludes   = ExcludeElement.ParseFromXml(options, node, vd);
                task.Parameters = ParameterElement.ParseFromXml(options, node, vd);
                task.Writer     = GetAttributeValue(node, WRITER, task.Writer);
                task.Styler     = GetAttributeValue(node, STYLER, task.Styler);
                TypeElement.ParseFromXml(node, task.Types);

                list.Add(task);
            }
            return(list);
        }