/// <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); }
#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><div class="plain"></div></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); }