Zonit.Extensions.Website 0.2.10

dotnet add package Zonit.Extensions.Website --version 0.2.10
                    
NuGet\Install-Package Zonit.Extensions.Website -Version 0.2.10
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zonit.Extensions.Website" Version="0.2.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zonit.Extensions.Website" Version="0.2.10" />
                    
Directory.Packages.props
<PackageReference Include="Zonit.Extensions.Website" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zonit.Extensions.Website --version 0.2.10
                    
#r "nuget: Zonit.Extensions.Website, 0.2.10"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zonit.Extensions.Website@0.2.10
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zonit.Extensions.Website&version=0.2.10
                    
Install as a Cake Addin
#tool nuget:?package=Zonit.Extensions.Website&version=0.2.10
                    
Install as a Cake Tool

Zonit.Extensions

Useful tools for Blazor


Abstractions Package

Zonit.Extensions.Abstractions - Interfaces and base abstractions

NuGet NuGet Downloads

dotnet add package Zonit.Extensions.Abstractions
Zonit.Extensions - Core utilities and extensions

NuGet NuGet Downloads

dotnet add package Zonit.Extensions

What's included:

  • Exceptions - Structured exception handling with i18n support, error codes, and strongly-typed error parameters
  • Reflection - Utility class for discovering assemblies and types that implement or inherit from a specified base type
  • Xml - Utility class for serializing objects to XML and deserializing XML back to objects
  • ValueObjects - Immutable value objects for common domain concepts (Price, Money, Title, Description, UrlSlug, Culture, Asset, FileSize, Color)

Asset Value Object - File Handling

The Asset struct is a complete file container with embedded metadata. MIME type is always detected from binary signature (magic bytes) - never trust file extension alone.

using Zonit.Extensions;

// From file
using var fileStream = File.OpenRead("document.pdf");
Asset asset = fileStream;  // Implicit conversion

// From bytes
byte[] data = await File.ReadAllBytesAsync("image.png");
Asset asset = data;

// Properties
Console.WriteLine(asset.Id);           // GUID - unique identifier
Console.WriteLine(asset.OriginalName); // "document.pdf"
Console.WriteLine(asset.UniqueName);   // "7a3b9c4d-1234-5678-90ab-cdef12345678.pdf"
Console.WriteLine(asset.MediaType);    // "application/pdf" (detected from signature!)
Console.WriteLine(asset.Signature);    // SignatureType.Pdf
Console.WriteLine(asset.Size);         // "1.5 MB" (FileSize VO)
Console.WriteLine(asset.Size.Megabytes); // 1.5
Console.WriteLine(asset.CreatedAt);    // 2026-01-21 12:34:56 UTC
Console.WriteLine(asset.Hash);         // SHA256 base64
Console.WriteLine(asset.Md5);          // MD5 base64

// Signature-based MIME detection (prevents extension spoofing)
// file.jpg that is actually WebP -> MediaType = "image/webp"
var uploaded = new Asset(bytes, "fake.jpg");
Console.WriteLine(uploaded.Signature);  // SignatureType.WebP
Console.WriteLine(uploaded.MediaType);  // "image/webp" (correct!)

// Implicit conversion back to Stream
Stream stream = asset;
await stream.CopyToAsync(outputStream);

FileSize Value Object - Like TimeSpan for File Sizes

// Create
var size = FileSize.FromMegabytes(1.5);
var size = new FileSize(1_500_000);  // bytes

// Convert
Console.WriteLine(size.Kilobytes);   // 1464.84
Console.WriteLine(size.Megabytes);   // 1.43
Console.WriteLine(size.Gigabytes);   // 0.0014
Console.WriteLine(size);           // "1.43 MB" (auto-formatted)

// Arithmetic
var total = size1 + size2;
var half = size / 2;

// Compare
if (fileSize > FileSize.FromMegabytes(10))
    Console.WriteLine("File too large!");

// Constants
FileSize.OneMegabyte      // 1 MB
FileSize.HundredMegabytes // 100 MB
FileSize.OneGigabyte      // 1 GB

See Asset.Examples.md for complete documentation.


Price & Money Value Objects - Monetary Values with Precision

using Zonit.Extensions;

// Price - always non-negative (products, costs)
Price price = 99.99m;
Price discounted = price.ApplyPercentage(-10);  // -10% discount
Console.WriteLine(price);                        // "99.99"
Console.WriteLine($"{price:C}");                 // "$99.99" (culture-dependent)

// Money - can be negative (balances, transactions)
Money balance = 500.00m;
Money withdrawal = -150.00m;
Money newBalance = balance + withdrawal;         // 350.00
Console.WriteLine(newBalance.IsPositive);        // true

// High precision internally (8 decimal places)
Console.WriteLine(price.ToFullPrecisionString()); // "99.99000000"

// IFormattable support
Console.WriteLine($"{price:C}");   // Currency format
Console.WriteLine($"{money:N2}");  // Number with 2 decimals

Color Value Object - OKLCH Color Space

The Color struct stores colors in OKLCH format for maximum precision and perceptual uniformity, with easy conversion to other formats.

using Zonit.Extensions;

// Create from various formats
Color color = Color.FromHex("#3498db");
Color color = Color.FromRgb(52, 152, 219);
Color color = Color.FromHsl(204, 0.7, 0.53);
Color color = Color.FromOklch(0.65, 0.15, 250);
Color color = "#3498db";  // Implicit conversion

// Access in different formats
Console.WriteLine(color.Hex);      // "#3498DB"
Console.WriteLine(color.CssRgb);   // "rgb(52, 152, 219)"
Console.WriteLine(color.CssHsl);   // "hsl(204, 70%, 53%)"
Console.WriteLine(color.CssOklch); // "oklch(65% 0.15 250)"

// RGB components
var (r, g, b) = color.Rgb;         // (52, 152, 219)
var (r, g, b, a) = color.Rgba;     // With alpha

// Color manipulation (OKLCH makes this perceptually uniform)
Color lighter = color.Lighten(0.1);
Color darker = color.Darken(0.1);
Color saturated = color.Saturate(0.05);
Color desaturated = color.Desaturate(0.05);
Color complement = color.Complementary;  // 180° hue rotation
Color gray = color.Grayscale;

// Mix colors
Color mixed = color1.Mix(color2, 0.5);  // 50% blend

// Alpha transparency
Color transparent = color.WithAlpha(0.5);
Console.WriteLine(transparent.HasAlpha);  // true

// Formatting
Console.WriteLine($"{color:hex}");    // "#3498DB"
Console.WriteLine($"{color:rgb}");    // "rgb(52, 152, 219)"
Console.WriteLine($"{color:hsl}");    // "hsl(204, 70%, 53%)"
Console.WriteLine($"{color:oklch}");  // "oklch(65% 0.15 250)"

Why OKLCH?

  • Perceptually uniform - equal changes produce equal perceived color changes
  • Better for color manipulation - adjusting lightness doesn't shift hue
  • Wider gamut support - can represent P3, Rec2020 colors
  • CSS Color Level 4 native support
  • Lossless storage - converting from OKLCH to other formats preserves maximum information

Blazor Website Extensions

Zonit.Extensions.Website.Abstractions - Interfaces and abstractions for Blazor

NuGet NuGet Downloads

dotnet add package Zonit.Extensions.Website.Abstractions 
Zonit.Extensions.Website - Blazor-specific components and utilities

NuGet NuGet Downloads

dotnet add package Zonit.Extensions.Website

What's included:

  • Components - Reusable Blazor components
  • Cookie handling with Blazor support (see below)

MudBlazor Integration

Zonit.Extensions.Website.MudBlazor - MudBlazor converters for Value Objects

NuGet NuGet Downloads

dotnet add package Zonit.Extensions.Website.MudBlazor

What's included:

  • ZonitTextField<T> - MudTextField with automatic Value Object converter
  • ZonitTextArea<T> - Multiline version for longer content
  • Built-in exception handling with automatic error messages
  • AOT and Trimming compatible (type inference at compile time)

Supported Value Objects: Title, Description, UrlSlug, Content, Url, Culture

Usage (type is inferred from @bind-Value):

@using Zonit.Extensions.MudBlazor

<ZonitTextField @bind-Value="Model.Title" Label="Title" />
<ZonitTextField @bind-Value="Model.Description" Label="Description" />
<ZonitTextField @bind-Value="Model.Slug" Label="URL Slug" />

@* For multiline content *@
<ZonitTextArea @bind-Value="Model.Content" Label="Content" />

No need to specify T="Title" - the compiler infers the type automatically!


Installation:

Add this in Routes.razor

@using Zonit.Extensions

<ZonitCookiesExtension />

Services in Program.cs

builder.Services.AddCookiesExtension();

App in Program.cs

app.UseCookiesExtension();

Example:

@page "/"
@rendermode InteractiveServer
@using Zonit.Extensions.Website
@inject ICookieProvider Cookie

@foreach (var cookie in Cookie.GetCookies())
{
    <p>@cookie.Name @cookie.Value</p>
}

API

    public CookieModel? Get(string key);
    public CookieModel Set(string key, string value, int days = 12 * 30);
    public CookieModel Set(CookieModel model);
    public Task<CookieModel> SetAsync(string key, string value, int days = 12 * 30);
    public Task<CookieModel> SetAsync(CookieModel model);
    public List<CookieModel> GetCookies();

We use SetAsync only in the Blazor circuit. It executes the JS code with the Cookies record.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Zonit.Extensions.Website:

Package Downloads
Zonit.Services.Dashboard

Package Description

Zonit.Services.Manager

Package Description

Zonit.SDK.Website

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.10 80 1/22/2026
0.2.9 78 1/21/2026
0.2.8 75 1/21/2026
0.2.7 90 1/16/2026
0.2.6 84 1/15/2026
0.2.4 83 1/15/2026
0.2.3 85 1/15/2026
0.2.2 82 1/15/2026
0.2.1 87 1/11/2026
0.2.0 81 1/11/2026
0.1.54 127 1/6/2026
0.1.53 87 1/4/2026
0.1.52 86 1/4/2026
0.1.51 88 1/2/2026
0.1.50 405 11/18/2025
0.1.27 148 8/16/2025
0.1.26 192 8/14/2025
0.1.25 293 7/26/2025
0.1.24 298 7/26/2025
0.1.23 338 7/26/2025
0.1.22 328 7/26/2025
0.1.21 323 7/26/2025
0.1.20 537 7/21/2025
0.1.19 524 7/21/2025
0.1.18 361 7/20/2025
0.1.17 162 6/27/2025
0.1.16 210 6/17/2025
0.1.15 187 6/17/2025
0.1.14 190 6/16/2025
0.1.13 190 6/16/2025
0.1.12 195 6/16/2025
0.1.11 189 6/16/2025
0.1.10 232 6/16/2025
0.1.9 144 6/6/2025
0.1.8 198 5/28/2025
0.1.7 197 5/27/2025
0.1.6 198 5/26/2025
0.1.5 197 5/26/2025
0.1.4 201 5/26/2025
0.1.3 198 5/26/2025
0.1.2 159 5/26/2025
0.1.1 155 5/25/2025
0.1.0 163 5/25/2025
0.0.41 601 2/5/2025
0.0.40 165 2/5/2025
0.0.39 164 2/5/2025
0.0.38 170 2/5/2025
0.0.37 204 2/5/2025
0.0.36 162 2/5/2025
0.0.34 187 2/1/2025
0.0.33 175 2/1/2025
0.0.32 164 1/30/2025
0.0.30 205 5/20/2024
0.0.23 187 5/20/2024
0.0.21 195 5/16/2024
0.0.18 187 5/15/2024
0.0.17 179 5/15/2024
0.0.15 198 5/14/2024
0.0.14 177 5/12/2024
0.0.13 149 5/11/2024