Example #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 ?? false) && nodes.Count == 0)
            {
                return(EmptyElementSyntax.Create(
                           StartTag.LessThan,
                           Name,
                           attributes,
                           SlashToken.Default,
                           EndTag.GreaterThan));
            }

            if (name.Equals(Name) &&
                (attributes.Equals(Attributes) || attributes.SequenceEqual(Attributes)) &&
                (nodes.Equals(Nodes) || nodes.SequenceEqual(Nodes)))
            {
                return(this);
            }

            return(Create(
                       StartTag.With(name, attributes),
                       nodes,
                       EndTag.With(EndTag.Name.With(name.Text))));
        }