예제 #1
0
        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);
            }
        }
예제 #2
0
        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))));
        }
예제 #3
0
        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)));
        }
예제 #4
0
        /// <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)));
        }
예제 #5
0
 public static IXmlElementSyntax AddAttribute(this IXmlElementSyntax self, XmlAttributeSyntax attribute)
 {
     return(self.WithAttributes(self.AttributesNode.Add(attribute)));
 }
예제 #6
0
 public virtual SyntaxNode VisitXmlAttribute(XmlAttributeSyntax node)
 {
     return(VisitXmlNode(node));
 }
 public virtual SyntaxNode VisitXmlAttribute(XmlAttributeSyntax node)
 {
     return VisitXmlNode(node);
 }