示例#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 VisitElementEndTag(ElementEndTagSyntax syntax)
        {
            var lessThan    = VisitAndConvert(syntax.LessThan);
            var slash       = VisitAndConvert(syntax.Slash);
            var name        = VisitAndConvert(syntax.Name);
            var greaterThan = VisitAndConvert(syntax.GreaterThan);

            if (SyntaxEquals(syntax.LessThan, lessThan) &&
                SyntaxEquals(syntax.Slash, slash) &&
                SyntaxEquals(syntax.Name, name) &&
                SyntaxEquals(syntax.GreaterThan, greaterThan))
            {
                return(syntax);
            }
            return(ElementEndTagSyntax.Create(lessThan, slash, name, greaterThan));
        }