コード例 #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))));
        }
コード例 #2
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)));
        }
コード例 #3
0
        public ElementEndTagSyntax With(NameToken name)
        {
            if (name == null || name.Equals(Name))
            {
                return(this);
            }

            return(new ElementEndTagSyntax(LessThan, Slash, name, GreaterThan));
        }
コード例 #4
0
 public ElementStartTagSyntax With(NameToken name = null, IImmutableList <AttributeSyntaxBase> attributes = null)
 {
     name       = name ?? Name;
     attributes = attributes ?? Attributes;
     if (attributes.Equals(Attributes) && name.Equals(Name))
     {
         return(this);
     }
     return(Create(LessThan, name, attributes, GreaterThan));
 }