Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Jun 25, 2024
1 parent 692872a commit 23252a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.301",
"version": "8.0.302",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
8 changes: 4 additions & 4 deletions src/DNTCommon.Web.Core/DNTCommon.Web.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DNTCommon.Web.Core provides common scenarios' solutions for ASP.NET Core applications.</Description>
<VersionPrefix>5.3.3</VersionPrefix>
<VersionPrefix>5.3.4</VersionPrefix>
<Authors>Vahid Nasiri</Authors>
<TargetFrameworks>net8.0;net7.0;net6.0;</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -55,7 +55,7 @@
<Using Include="System.Net.Http.Headers"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.155">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.158">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -71,7 +71,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.26.0.92422">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.27.0.93347">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -80,7 +80,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2"/>
<PackageReference Include="DNTPersianUtils.Core" Version="6.3.0"/>
<PackageReference Include="DNTPersianUtils.Core" Version="6.3.1"/>
<PackageReference Include="MailKit" Version="4.6.0"/>
<PackageReference Include="HtmlAgilityPack" Version="1.11.61"/>
<PackageReference Include="IPAddressRange" Version="6.0.0"/>
Expand Down
49 changes: 29 additions & 20 deletions src/DNTCommon.Web.Core/Logging/HtmlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,58 @@ namespace DNTCommon.Web.Core;
/// </summary>
public static class HtmlExtensions
{
/// <summary>
/// Creates a `strong` html tag
/// </summary>
public static string MakeItStrong(this string text) => $"<strong>{text}</strong>";

/// <summary>
/// Creates a simple bootstrap table
/// </summary>
/// <param name="caption"></param>
/// <param name="headers"></param>
/// <param name="rows"></param>
/// <returns></returns>
public static string CreateHtmlTable(string caption,
IEnumerable<string> headers,
IEnumerable<IEnumerable<string>> rows)
public static string CreateHtmlTable(string? caption,
IList<string>? headers,
IEnumerable<IEnumerable<string>> rows,
string tableClass = "table table-bordered table-sm caption-top table-striped table-hover w-auto mx-auto",
string? tableAttributes = null)
{
ArgumentNullException.ThrowIfNull(headers);
ArgumentNullException.ThrowIfNull(rows);

var sb = new StringBuilder();
sb.AppendLine("<br/>");
sb.AppendLine("<table class=\"table table-sm caption-top table-striped table-hover\">");
sb.AppendLine(CultureInfo.InvariantCulture, $"<caption>{caption}</caption>");
sb.AppendLine("<thead><tr>");
sb.AppendLine(CultureInfo.InvariantCulture, $"<table {tableAttributes} class='{tableClass}'>");

foreach (var header in headers)
if (!string.IsNullOrWhiteSpace(caption))
{
sb.AppendLine(CultureInfo.InvariantCulture, $"<th scope=\"col\">{header}</th>");
sb.AppendLine(CultureInfo.InvariantCulture, $"<caption>{caption}</caption>");
}

sb.AppendLine("</tr></thead>");
if (headers?.Count > 0)
{
sb.AppendLine(value: "<thead><tr>");

foreach (var header in headers)
{
sb.AppendLine(CultureInfo.InvariantCulture, $"<th scope=\"col\">{header}</th>");
}

sb.AppendLine(value: "</tr></thead>");
}

sb.AppendLine("<tbody class=\"table-group-divider\">");
sb.AppendLine(value: "<tbody class=\"table-group-divider\">");

foreach (var row in rows)
{
sb.AppendLine("<tr>");
sb.AppendLine(value: "<tr>");

foreach (var item in row)
{
sb.AppendLine(CultureInfo.InvariantCulture, $"<td>{item}</td>");
}

sb.AppendLine("</tr>");
sb.AppendLine(value: "</tr>");
}

sb.AppendLine("</tbody>");
sb.AppendLine("</table>");
sb.AppendLine(value: "</tbody>");
sb.AppendLine(value: "</table>");

return sb.ToString();
}
Expand Down

0 comments on commit 23252a6

Please sign in to comment.