public override void OnSaveSettings(XmlElement moduleElement) { for (int i = 0; i < 5; i++) { XmlElement element = moduleElement.AppendElement("option" + i); element.InnerText = "value " + (i*5); moduleElement.AppendChild(element); } }
public virtual void OnSaveSettings(XmlElement moduleElement) { foreach (var activablePart in Parts.OfType<IActivablePart>()) { moduleElement.AppendElement( activablePart.GetCodeName(), activablePart.IsEnabled.ToString()); } }
public override void OnSaveSettings(XmlElement moduleElement) { base.OnSaveSettings(moduleElement); foreach (var option in Enum.GetValues(typeof(ModOptions)) .OfType<ModOptions>() .Where(o => o != 0)) { moduleElement.AppendElement( option.ToString().ToUpper(), s_activeOptions.HasFlag(option).ToString()); } }
private static void CopyConfiguration(PackageGroup group, string parentName, string childName, XmlElement source, XmlElement target) { string aggregateXpath = string.Format("{0}/{1}/@name", parentName, childName); List<string> names = group.FilterNames(source.Aggregate(aggregateXpath, XmlNamespaces.Manager)); if (names.Count != 0) { XmlNode parentNode = target.AppendElement(parentName.Replace("p:", string.Empty), XmlNamespaces.ProjectConfigurationNamespace); foreach (string name in names) { string xpath = string.Format("{0}/{1}[@name='{2}']", parentName, childName, name); parentNode.AppendChild(target.OwnerDocument.ImportNode( source.SelectSingleNode(xpath, XmlNamespaces.Manager), true)); } } }
private void SynchronizeElements(XmlElement targetElement, XmlElement sourceElement) { foreach (XmlAttribute attr in sourceElement.Attributes) { if (targetElement.Attributes[attr.Name] == null) targetElement.SetAttribute(attr.Name, attr.Value); } foreach (XmlElement sourceChild in sourceElement.SelectNodes("*")) { XmlNamespaceManager nm = new XmlNamespaceManager(new NameTable()); nm.AddNamespace("temp", sourceElement.NamespaceURI); XmlElement targetChild = targetElement.SelectSingleElement(string.Format("temp:{0}", sourceChild.LocalName), nm); if (targetChild == null) { targetChild = targetElement.OwnerDocument.CreateElement(sourceChild.Name, sourceChild.NamespaceURI); targetElement.AppendElement(targetElement.OwnerDocument.ImportNode(sourceChild, true)); } this.SynchronizeElements(targetChild, sourceChild); } }