AppendDataNode() public method

Creates a mod:data node in the current module.
If this method is invoked with no arguments, a mod:data element will be created (if it doesn't exist in the current module) and the final mod:data element will be returned. If an element whose name is mod:data is supplied, if will either be appended to the current module (if the module doesn't have a mod:data element already) or it will replace the existing mod:data element if one exists already. The node that will be returned will be the appended copy of the specified dataNode.
public AppendDataNode ( XmlNode dataNode = null ) : XmlNode
dataNode System.Xml.XmlNode Optional data node to add to the current module's element.
return System.Xml.XmlNode
Exemplo n.º 1
0
        public ModuleResult ProcessElement(XmlElement moduleElement, ViewConfiguration configuration)
        {
            ModuleResult result = new ModuleResult(moduleElement);
            XmlDocument ownerDoc = moduleElement.OwnerDocument;
            XmlElement dataElement = ownerDoc.CreateElement("mod:data", XmlNamespaces.ModulesNamespace);
            XmlElement metaElement = dataElement.AppendElement("mod:meta", XmlNamespaces.ModulesNamespace);

            SageContext context = configuration.Context;
            foreach (MetaViewInfo info in context.ProjectConfiguration.MetaViews.Values)
            {
                XmlElement viewElement = metaElement.AppendElement("mod:view", XmlNamespaces.ModulesNamespace);
                viewElement.SetAttribute("name", info.Name);
                viewElement.InnerText = info.Description;
            }

            result.AppendDataNode(dataElement);
            return result;
        }
Exemplo n.º 2
0
        public ModuleResult ProcessElement(XmlElement moduleElement, ViewConfiguration configuration)
        {
            SageContext context = configuration.Context;
            this.moduleElement = moduleElement;

            XmlNode configNode = moduleElement.SelectSingleNode("mod:config", XmlNamespaces.Manager);
            if (configNode == null)
            {
                log.ErrorFormat("The {0} element doesn't have the mod:config node. Skipping further work", typeof(DirectoryTreeModule).FullName);
                return new ModuleResult(moduleElement, ModuleResultStatus.MissingParameters);
            }

            XmlNode valueNode;
            if ((valueNode = configNode.SelectSingleNode("mod:path", XmlNamespaces.Manager)) == null)
            {
                log.ErrorFormat("The {0} element doesn't have the mod:config/mod:path node. Skipping further work", typeof(DirectoryTreeModule).FullName);
                return new ModuleResult(moduleElement, ModuleResultStatus.MissingParameters);
            }

            this.path = valueNode.InnerText;
            this.absolutePath = this.GetDirectoryPath(moduleElement, context);

            if (configNode.SelectSingleNode("mod:recursive", XmlNamespaces.Manager) != null)
                this.recursive = true;

            if (configNode.SelectSingleNode("mod:filesOnly", XmlNamespaces.Manager) != null)
                this.filesOnly = true;

            if (configNode.SelectSingleNode("mod:directoriesOnly", XmlNamespaces.Manager) != null)
                this.directoriesOnly = true;

            if (configNode.SelectSingleNode("mod:absolutePaths", XmlNamespaces.Manager) != null)
                this.absolutePaths = true;

            if ((valueNode = configNode.SelectSingleNode("mod:pattern", XmlNamespaces.Manager)) != null)
                this.pattern = valueNode.InnerText.Trim();

            if ((valueNode = configNode.SelectSingleNode("mod:expression", XmlNamespaces.Manager)) != null)
            {
                string text = valueNode.InnerText.Trim();
                if (!string.IsNullOrEmpty(text))
                {
                    try
                    {
                        this.expression = new Regex(text);
                    }
                    catch (Exception ex)
                    {
                        log.WarnFormat("Invalid regular expression text: '{0}': {1}", text, ex.Message);
                    }
                }
            }

            if (!Directory.Exists(this.absolutePath))
            {
                log.WarnFormat("The directory '{0}' (mapped to '{1}') doesn't exist.", this.path, this.absolutePath);
                return new ModuleResult(moduleElement, ModuleResultStatus.NoData);
            }

            ModuleResult result = new ModuleResult(moduleElement);
            result.AppendDataNode(ScanDirectory(absolutePath, context));

            return result;
        }