Example #1
0
        protected internal override void SaveToElement(PomXmlElement profileElem)
        {
            var idElem = profileElem.ReadOrCreateElement("id");

            if (string.IsNullOrEmpty(Id))
            {
                idElem.Remove();
            }
            else
            {
                idElem.Value = Id;
            }

            base.SaveToElement(profileElem);
        }
Example #2
0
        internal protected virtual void SaveToElement(PomXmlElement element)
        {
            //writing modules
            var modulesNode = element.ReadOrCreateElement("modules");

            if (!Modules.Any())
            {
                modulesNode.Remove();
            }
            else
            {
                modulesNode.RemoveAllChildElements();
                foreach (Module module in Modules)
                {
                    if (!string.IsNullOrEmpty(module.Path))
                    {
                        var moduleNode = modulesNode.CreateElement("module");
                        module.SaveTo(moduleNode);
                    }
                }
            }

            //writing dependencies
            var dependenciesNode = element.ReadOrCreateElement("dependencies");

            if (!Dependencies.Any())
            {
                dependenciesNode.Remove();
            }
            else
            {
                dependenciesNode.RemoveAllChildElements();
                foreach (Dependency dependency in Dependencies)
                {
                    var dependencyNode = dependenciesNode.CreateElement("dependency");
                    dependency.SaveToElement(dependencyNode);
                }
            }

            //writing properties
            var propertiesNode = element.ReadOrCreateElement("properties");

            if (!Properties.Any())
            {
                propertiesNode.Remove();
            }
            else
            {
                propertiesNode.RemoveAllChildElements();
                foreach (Property prop in Properties)
                {
                    prop.SaveTo(propertiesNode);
                }
            }

            var buildNode = element.ReadOrCreateElement("build");

            if (!Plugins.Any() && !PluginManagement.Any())             // empty build section
            {
                buildNode.Remove();
            }
            else
            {
                var pluginsNode = buildNode.ReadOrCreateElement("plugins");
                if (!Plugins.Any())
                {
                    pluginsNode.Remove();
                }
                else
                {
                    pluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in Plugins)
                    {
                        var pluginNode = pluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }

                var pluginManagementNode        = buildNode.ReadOrCreateElement("pluginManagement");
                var pluginManagementPluginsNode = pluginManagementNode.ReadOrCreateElement("plugins");

                if (!PluginManagement.Any())
                {
                    pluginManagementNode.Remove();
                }
                else
                {
                    pluginManagementPluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in PluginManagement)
                    {
                        var pluginNode = pluginManagementPluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }
            }
        }