Пример #1
0
        /// <summary>
        /// Opens a new <c>&lt;tr&gt;</c> block, adding the given CSS class attribute if provided,
        /// after first closing the currently open row.
        /// </summary>
        /// <remarks>
        /// Note: Do not use this method with a
        /// <see cref="OpenTable(FluentRenderTreeBuilder, string?, string?, int)">OpenTable(...)</see>;
        /// instead, use <see cref="NewRow(FluentRenderTreeBuilder, string?, int)">NewRow(...)</see>.
        /// </remarks>
        /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param>
        /// <param name="class">The optional CSS class name for the new table row.</param>
        /// <param name="line">The source code line number used to generate the sequence number.</param>
        public static FluentRenderTreeBuilder NewAutoRow(this FluentRenderTreeBuilder frtb,
                                                         string? @class = null, [CallerLineNumber] int line = 0)
        {
            // we can't call Close() here because Auto Table closes itself too, so go direct to underlying builder
            frtb.Builder.CloseElement();             // tr

            // as we didn't call Close() above, we now can't call Element(), so go direct again
            frtb.Builder.OpenElement(frtb.GetSequence(line), "tr");

            return(frtb.Class(@class, line));
        }
        /// <summary>
        /// Opens a new <c>&lt;li&gt;</c> block within an
        /// <see cref="OpenAutoList(FluentRenderTreeBuilder, string?, string?, string?, object?, int)">
        /// OpenAutoList(...)</see> or an
        /// <see cref="OpenAutoOrderedList(FluentRenderTreeBuilder, string?, string?, string?, object?, int)">
        /// OpenAutoOrderedList(...)</see>,
        /// adding the given CSS class attribute, and setting
        /// the key, if provided, after first closing the currently open item.
        /// </summary>
        /// <remarks>
        /// Note: Do not use this method within a
        /// <see cref="OpenList(FluentRenderTreeBuilder, string?, string?, int)">OpenList(...)</see> or an
        /// <see cref="OpenOrderedList(FluentRenderTreeBuilder, string?, string?, int)">OpenOrderedList(...)</see>;
        /// instead, use <see cref="NewItem(FluentRenderTreeBuilder, string?, object?, int)">NewItem(...)</see>.
        /// </remarks>
        /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param>
        /// <param name="class">The optional CSS class name for the new list item.</param>
        /// <param name="key">The optional key to set for this list item.</param>
        /// <param name="line">The source code line number used to generate the sequence number.</param>
        public static FluentRenderTreeBuilder NewAutoItem(this FluentRenderTreeBuilder frtb,
                                                          string? @class = null, object?key = null, [CallerLineNumber] int line = 0)
        {
            // we can't call Close() here because Auto List closes itself too!
            frtb.Builder.CloseElement();             // li

            // as we didn't call Close() above, we now can't call Element(), so go direct again
            frtb.Builder.OpenElement(frtb.GetSequence(line), "li");

            return(frtb
                   .SetKey(key)
                   .Class(@class, line));
        }