예제 #1
0
        public override ElementSyntaxBase With(
            NameToken name = null,
            IImmutableList <AttributeSyntaxBase> attributes = null,
            IImmutableList <NodeSyntax> nodes = null,
            bool?isEmpty = null)
        {
            name       = name ?? Name;
            nodes      = nodes ?? Nodes;
            attributes = attributes ?? Attributes;

            if ((isEmpty ?? true) && nodes.Count == 0)
            {
                if (name.Equals(Name) &&
                    (attributes.Equals(Attributes) || attributes.SequenceEqual(Attributes)))
                {
                    return(this);
                }

                return(new EmptyElementSyntax(LessThan, name, attributes, Slash, GreaterThan));
            }

            return(ElementSyntax.Create(
                       ElementStartTagSyntax.Create(LessThan, name, attributes, GreaterThanToken.Default),
                       nodes,
                       ElementEndTagSyntax.Create(
                           LessThanToken.Default,
                           SlashToken.Default,
                           name,
                           GreaterThan)));
        }
예제 #2
0
        protected virtual SyntaxBase VisitElement(ElementSyntax syntax)
        {
            var startTag = VisitAndConvert(syntax.StartTag);
            var nodes    = VisitAndConvert(syntax.Nodes);
            var endTag   = VisitAndConvert(syntax.EndTag);

            if (SyntaxEquals(syntax.StartTag, startTag) &&
                ReferenceEquals(syntax.Nodes, nodes) &&
                SyntaxEquals(syntax.EndTag, endTag))
            {
                return(syntax);
            }
            return(ElementSyntax.Create(startTag, nodes, endTag));
        }