Ejemplo n.º 1
0
        /// <summary>
        /// Create a duplicate tag, recursively cloning any contents
        /// </summary>
        [NotNull] public TagContent Clone()
        {
            var dup = new TagContent {
                Properties = Properties,
                IsEmpty    = IsEmpty,
                Tag        = Tag,
                Text       = Text
            };

            if (Contents != null && Contents.Any())
            {
                dup.Contents = Contents.Select(c => c?.Clone()).ToList();
            }
            return(dup);
        }
Ejemplo n.º 2
0
Archivo: T.cs Proyecto: i-e-b/T.g
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming

        /// <summary>
        /// Create a new tag.
        /// <para>Example: <code>T.g("div", "class", "plain")</code> would give <code>&lt;div class="plain"&gt;&lt;/div&gt;</code> </para>
        /// </summary>
        /// <param name="tagName">Name of the tag</param>
        /// <param name="properties">list alternating between property name and value</param>
        [NotNull] public static TagContent g(string tagName, params string[] properties)
        {
            if (tagName == null)
            {
                tagName = "";
            }
            var empty = tagName.EndsWith("/", StringComparison.Ordinal);
            var t     = new TagContent
            {
                Tag      = empty ? tagName.TrimEnd('/') : tagName,
                IsEmpty  = empty,
                Contents = null
            };

            t.SerialiseProperties(properties);

            return(t);
        }