From ecfb20acb85d923335099bc7ea29293a81d6d155 Mon Sep 17 00:00:00 2001 From: SandRock Date: Thu, 23 Mar 2023 11:45:18 +0100 Subject: [PATCH] SrkToolkit.Web: restore Submit HtmlHelper extension --- .../SrkHtmlExtensions.cs | 322 +++++++++--------- 1 file changed, 161 insertions(+), 161 deletions(-) diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs index 669d3c1..b103daf 100644 --- a/Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs @@ -27,7 +27,7 @@ namespace SrkToolkit.Web using SrkToolkit.Web.Open; using System; using System.Collections.Generic; - using System.Globalization; + using System.Globalization; using System.Linq; using System.Text; using System.Linq.Expressions; @@ -545,161 +545,161 @@ public static HtmlString DisplayTime(this IHtmlHelper html, TimeSpan date, bool return new HtmlString(display); } } - - /// - /// Displays a duration. - /// - /// - /// - /// - public static HtmlString DisplayTimeSpan(this IHtmlHelper html, TimeSpan? value) - { - return DisplayTimeSpan(html, value, false, null, true); - } - - /// - /// Displays a duration. - /// - /// - /// - /// - /// - public static HtmlString DisplayTimeSpan(this IHtmlHelper html, TimeSpan? value, bool showMilliseconds) - { - return DisplayTimeSpan(html, value, showMilliseconds, null, true); - } - - /// - /// Displays a duration. - /// - /// - /// - /// - /// - /// - /// - public static HtmlString DisplayTimeSpan(this IHtmlHelper html, TimeSpan? value, bool showMilliseconds, object nullValue, bool asHtml) - { - var b = new StringBuilder(); - string tmp; - - if (value == null && nullValue is TimeSpan) - { - value = (TimeSpan)nullValue; - } - - if (value != null) - { - tmp = value.Value.ToInvariantString(); - - var lang = CultureInfo.CurrentCulture; - var title = value.Value.ToInvariantString() - + " | " + value.Value.TotalDays.ToString("F2", lang) + " days" - + " | " + value.Value.TotalHours.ToString("F2", lang) + " hours" - + " | " + value.Value.TotalSeconds.ToString("F2", lang) + " seconds" - + " | " + value.Value.TotalMilliseconds.ToString("F2", lang) + " milliseconds" - ; - - if (asHtml) - { - b.Append(@""); - } - - if (value.Value.Days != 0) - { - tmp = Math.Abs(value.Value.Days).ToString(); - if (asHtml) - { - b.Append(@""); - b.Append(tmp); - b.Append(@"."); - } - else - { - b.Append(tmp); - b.Append("."); - } - } - - if (value.Value.Days != 0 || value.Value.Hours != 0) - { - tmp = Math.Abs(value.Value.Hours).ToString("00"); - if (asHtml) - { - b.Append(@""); - b.Append(tmp); - b.Append(@":"); - } - else - { - b.Append(tmp); - b.Append(":"); - } - } - - tmp = Math.Abs(value.Value.Minutes).ToString("00"); - if (asHtml) - { - b.Append(@""); - b.Append(tmp); - b.Append(@":"); - } - else - { - b.Append(tmp); - b.Append(":"); - } - - tmp = Math.Abs(value.Value.Seconds).ToString("00"); - if (asHtml) - { - b.Append(@""); - b.Append(tmp); - b.Append(@""); - } - else - { - b.Append(tmp); - } - - if (showMilliseconds) - { - tmp = Math.Abs(value.Value.Milliseconds).ToString("000"); - if (asHtml) - { - b.Append(@"."); - b.Append(tmp); - b.Append(@""); - } - else - { - b.Append("."); - b.Append(tmp); - } - } - - if (asHtml) b.Append(@""); - } - else if (nullValue != null) - { - tmp = nullValue.ToString(); - if (asHtml) - { - b.Append(@""); - b.Append(tmp.ProperHtmlEscape()); - b.Append(@""); - } - else - { - b.Append(tmp); - } - } - - return new HtmlString(b.ToString()); - } - + + /// + /// Displays a duration. + /// + /// + /// + /// + public static HtmlString DisplayTimeSpan(this IHtmlHelper html, TimeSpan? value) + { + return DisplayTimeSpan(html, value, false, null, true); + } + + /// + /// Displays a duration. + /// + /// + /// + /// + /// + public static HtmlString DisplayTimeSpan(this IHtmlHelper html, TimeSpan? value, bool showMilliseconds) + { + return DisplayTimeSpan(html, value, showMilliseconds, null, true); + } + + /// + /// Displays a duration. + /// + /// + /// + /// + /// + /// + /// + public static HtmlString DisplayTimeSpan(this IHtmlHelper html, TimeSpan? value, bool showMilliseconds, object nullValue, bool asHtml) + { + var b = new StringBuilder(); + string tmp; + + if (value == null && nullValue is TimeSpan) + { + value = (TimeSpan)nullValue; + } + + if (value != null) + { + tmp = value.Value.ToInvariantString(); + + var lang = CultureInfo.CurrentCulture; + var title = value.Value.ToInvariantString() + + " | " + value.Value.TotalDays.ToString("F2", lang) + " days" + + " | " + value.Value.TotalHours.ToString("F2", lang) + " hours" + + " | " + value.Value.TotalSeconds.ToString("F2", lang) + " seconds" + + " | " + value.Value.TotalMilliseconds.ToString("F2", lang) + " milliseconds" + ; + + if (asHtml) + { + b.Append(@""); + } + + if (value.Value.Days != 0) + { + tmp = Math.Abs(value.Value.Days).ToString(); + if (asHtml) + { + b.Append(@""); + b.Append(tmp); + b.Append(@"."); + } + else + { + b.Append(tmp); + b.Append("."); + } + } + + if (value.Value.Days != 0 || value.Value.Hours != 0) + { + tmp = Math.Abs(value.Value.Hours).ToString("00"); + if (asHtml) + { + b.Append(@""); + b.Append(tmp); + b.Append(@":"); + } + else + { + b.Append(tmp); + b.Append(":"); + } + } + + tmp = Math.Abs(value.Value.Minutes).ToString("00"); + if (asHtml) + { + b.Append(@""); + b.Append(tmp); + b.Append(@":"); + } + else + { + b.Append(tmp); + b.Append(":"); + } + + tmp = Math.Abs(value.Value.Seconds).ToString("00"); + if (asHtml) + { + b.Append(@""); + b.Append(tmp); + b.Append(@""); + } + else + { + b.Append(tmp); + } + + if (showMilliseconds) + { + tmp = Math.Abs(value.Value.Milliseconds).ToString("000"); + if (asHtml) + { + b.Append(@"."); + b.Append(tmp); + b.Append(@""); + } + else + { + b.Append("."); + b.Append(tmp); + } + } + + if (asHtml) b.Append(@""); + } + else if (nullValue != null) + { + tmp = nullValue.ToString(); + if (asHtml) + { + b.Append(@""); + b.Append(tmp.ProperHtmlEscape()); + b.Append(@""); + } + else + { + b.Append(tmp); + } + } + + return new HtmlString(b.ToString()); + } + /// /// Returns the date (to UTC) in JavaScript format like 'new Date(123456789000)'. /// @@ -1033,7 +1033,7 @@ public static MvcForm BeginFormEx(this IHtmlHelper IHtmlHelper, object htmlAttri #endregion #region Submit -/* + /// /// Returns a submit input element by using the specified HTML helper and the name of the form field. /// @@ -1045,7 +1045,7 @@ public static HtmlString Submit(this IHtmlHelper html, string value) var builder = new TagBuilder("input"); builder.MergeAttribute("type", "submit"); builder.MergeAttribute("value", value); - return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return builder.ToHtmlString(); } /// @@ -1061,7 +1061,7 @@ public static HtmlString Submit(this IHtmlHelper html, string value, string name builder.MergeAttribute("type", "submit"); builder.MergeAttribute("name", name); builder.MergeAttribute("value", value); - return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return builder.ToHtmlString(); } /// @@ -1080,9 +1080,9 @@ public static HtmlString Submit(this IHtmlHelper html, string value, string name builder.MergeAttribute("type", "submit"); builder.MergeAttribute("name", name); builder.MergeAttribute("value", value); - return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return builder.ToHtmlString(); } -*/ + #endregion #region File