Пример #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);
 }