Skip to content

codecapital/CodeCapital.AspNetCore

Repository files navigation

CodeCapital.AspNetCore

ASP.NET Core libraries.

.NET

CodeCapital.AspNetCore.Mvc.TagHelpers

NuGet

  • Json Flattener
  • Tag Helpers
    • asp-class
    • asp-if [negate]
  • Razor to String Renderer
  • Configuration in ASP.NET Core
    • AddRemoteJsonFile(url)
  • Services
    • MailGun
    • ReCaptcha v2
  • RazorLibrary
    • Calendar (blazor)
    • Table (blazor, with column sorting)

Json Flattener

Namespace: CodeCapital.System.Text.Json

This library flattens json string into List<dynamic>.

var flattener = new JsonFlattener();
var list = flattener.Flatten(json);

ASP.NET Core TagHelpers

Namespace: CodeCapital.AspNetCore.Mvc.TagHelpers

Conditional Add Class (asp-class-something="")

ASP.NET Core

    <p asp-class-text-success="@Model.IsSuccess">Hello, World!</p>

HTML (If a condition is true, a class attribute is added to html tag)

    <p class="text-success">Hello, World!</p>

If Condition (asp-if="", <asp-if></asp-if> )

ASP.NET Core

<asp-if condition="@Model.IsSuccess">
    <p>Hello, World!</p>
<asp-if>

<p asp-if="@Model.IsSucces">Hello, World!</p>

HTML (If a condition is true)

    <p>Hello, World!</p>

Negate

ASP.NET Core

<asp-if condition="@Model.IsSuccess" negate>
    <p>Hello, World!</p>
<asp-if>

<p asp-if="@Model.IsSucces" negate>Hello, World!</p>

HTML (If a condition is true, nothing renders.)

References

https://stackoverflow.com/questions/58512542/read-a-json-file-and-generate-string-keys-with-values-in-a-dictionary-like-objec https://stackoverflow.com/questions/7394551/c-sharp-flattening-json-structure