/// <summary> /// Applies properties from the specified type to this instance. /// </summary> /// <param name="element">The element to act as a template to copy from.</param> public virtual void CopyFrom(ProjectElement element) { ErrorUtilities.VerifyThrowArgumentNull(element, "element"); ErrorUtilities.VerifyThrowArgument(this.GetType().IsEquivalentTo(element.GetType()), "element"); if (this == element) { return; } // Remove all the current attributes and textual content. this.XmlElement.RemoveAllAttributes(); if (this.XmlElement.ChildNodes.Count == 1 && this.XmlElement.FirstChild.NodeType == XmlNodeType.Text) { this.XmlElement.RemoveChild(this.XmlElement.FirstChild); } // Ensure the element name itself matches. this.ReplaceElement(XmlUtilities.RenameXmlElement(this.XmlElement, element.XmlElement.Name, XMakeAttributes.defaultXmlNamespace)); // Copy over the attributes from the template element. foreach (XmlAttribute attribute in element.XmlElement.Attributes) { this.XmlElement.SetAttribute(attribute.LocalName, attribute.NamespaceURI, attribute.Value); } // If this element has pure text content, copy that over. if (element.XmlElement.ChildNodes.Count == 1 && element.XmlElement.FirstChild.NodeType == XmlNodeType.Text) { this.XmlElement.AppendChild(this.XmlElement.OwnerDocument.CreateTextNode(element.XmlElement.FirstChild.Value)); } this.MarkDirty("CopyFrom", null); }
/// <inheritdoc/> public override void CopyFrom(ProjectElement element) { ErrorUtilities.VerifyThrowArgumentNull(element, "element"); ErrorUtilities.VerifyThrowArgument(this.GetType().IsEquivalentTo(element.GetType()), "element"); if (this == element) { return; } this.Label = element.Label; var other = (ProjectExtensionsElement)element; this.Content = other.Content; this.MarkDirty("CopyFrom", null); }
/// <summary> /// Applies properties from the specified type to this instance. /// </summary> /// <param name="element">The element to act as a template to copy from.</param> public virtual void CopyFrom(ProjectElement element) { ErrorUtilities.VerifyThrowArgumentNull(element, "element"); ErrorUtilities.VerifyThrowArgument(this.GetType().IsEquivalentTo(element.GetType()), "element"); if (this == element) { return; } // Remove all the current attributes and textual content. this.XmlElement.RemoveAllAttributes(); if (this.XmlElement.ChildNodes.Count == 1 && this.XmlElement.FirstChild.NodeType == XmlNodeType.Text) { this.XmlElement.RemoveChild(this.XmlElement.FirstChild); } // Ensure the element name itself matches. this.ReplaceElement(XmlUtilities.RenameXmlElement(this.XmlElement, element.XmlElement.Name, XmlElement.NamespaceURI)); // Copy over the attributes from the template element. foreach (XmlAttribute attribute in element.XmlElement.Attributes) { this.XmlElement.SetAttribute(attribute.LocalName, attribute.NamespaceURI, attribute.Value); } // If this element has pure text content, copy that over. if (element.XmlElement.ChildNodes.Count == 1 && element.XmlElement.FirstChild.NodeType == XmlNodeType.Text) { this.XmlElement.AppendChild(this.XmlElement.OwnerDocument.CreateTextNode(element.XmlElement.FirstChild.Value)); } this._expressedAsAttribute = element._expressedAsAttribute; this.MarkDirty("CopyFrom", null); }
/// <inheritdoc/> public override void CopyFrom(ProjectElement element) { ErrorUtilities.VerifyThrowArgumentNull(element, "element"); ErrorUtilities.VerifyThrowArgument(this.GetType().IsEquivalentTo(element.GetType()), "element"); if (this == element) { return; } this.Label = element.Label; var other = (ProjectExtensionsElement)element; this.Content = other.Content; this.MarkDirty("CopyFrom", null); }