public override SyntaxNode VisitXmlAttribute(XmlAttributeSyntax node) { bool anyChanges = false; var newName = ((XmlNameSyntax)Visit(node.NameNode)); if (node.NameNode != newName) { anyChanges = true; } var newEqualsToken = ((PunctuationSyntax)Visit(node.Equals)); if (node.Equals != newEqualsToken) { anyChanges = true; } var newValue = ((XmlNodeSyntax)Visit(node.ValueNode)); if (node.ValueNode != newValue) { anyChanges = true; } if (anyChanges) { return(new XmlAttributeSyntax(newName, newEqualsToken, newValue)); } else { return(node); } }
public static XmlAttributeSyntax WithPrefixName(this XmlAttributeSyntax attribute, string prefixName) { var existingName = attribute.NameNode; var existingPrefix = existingName.PrefixNode; var newName = SyntaxFactory.XmlNameToken(prefixName, null, null); return(attribute.WithName(existingName.WithPrefix(existingPrefix.WithName(newName)))); }
public static XmlAttributeSyntax WithLocalName(this XmlAttributeSyntax attribute, string localName) { var existingName = attribute.NameNode; var existingLocalName = existingName.LocalNameNode; var newName = SyntaxFactory.XmlNameToken(localName, null, null); return(attribute.WithName(existingName.WithLocalName(newName))); }
/// <summary> /// Return a new <see cref="XmlAttributeSyntax"/> instance with /// the supplied string attribute value /// </summary> public static XmlAttributeSyntax WithValue(this XmlAttributeSyntax attribute, string attributeValue) { var textTokens = SyntaxFactory.SingletonList(SyntaxFactory.XmlTextLiteralToken(attributeValue, null, null)); return(attribute.WithValue(attribute.ValueNode.WithTextTokens(textTokens))); }
public static IXmlElementSyntax AddAttribute(this IXmlElementSyntax self, XmlAttributeSyntax attribute) { return(self.WithAttributes(self.AttributesNode.Add(attribute))); }
public virtual SyntaxNode VisitXmlAttribute(XmlAttributeSyntax node) { return(VisitXmlNode(node)); }
public virtual SyntaxNode VisitXmlAttribute(XmlAttributeSyntax node) { return VisitXmlNode(node); }