Dosaic.Extensions.Abstractions
1.2.7
See the version list below for details.
dotnet add package Dosaic.Extensions.Abstractions --version 1.2.7
NuGet\Install-Package Dosaic.Extensions.Abstractions -Version 1.2.7
<PackageReference Include="Dosaic.Extensions.Abstractions" Version="1.2.7" />
<PackageVersion Include="Dosaic.Extensions.Abstractions" Version="1.2.7" />
<PackageReference Include="Dosaic.Extensions.Abstractions" />
paket add Dosaic.Extensions.Abstractions --version 1.2.7
#r "nuget: Dosaic.Extensions.Abstractions, 1.2.7"
#:package Dosaic.Extensions.Abstractions@1.2.7
#addin nuget:?package=Dosaic.Extensions.Abstractions&version=1.2.7
#tool nuget:?package=Dosaic.Extensions.Abstractions&version=1.2.7
Dosaic.Extensions.Abstractions
Shared value-object and pagination abstractions for Dosaic-based .NET services. Provides lightweight, framework-agnostic types for paginated responses, monetary values, and typed quantity values.
Installation
dotnet add package Dosaic.Extensions.Abstractions
Types
| Type | Kind | Description |
|---|---|---|
Page |
record | Pagination metadata: current page index, page size, total elements, total pages |
PagedList<T> |
record | Combines a list of items with a Page metadata object |
CurrencyValue |
class | Monetary value with a decimal amount, currency symbol, and ISO currency code |
Quantity<T> |
abstract record | Generic quantity with a typed Value and a Unit string |
QuantityCount |
abstract record | Specialisation of Quantity<int> with the unit fixed to "Count" |
Usage
Page
Page holds pagination metadata returned alongside a result set. Null size defaults to int.MaxValue (unbounded), and null current defaults to 0.
// Create manually
var page = new Page(size: 10, current: 2, totalElements: 100, totalPages: 10);
Console.WriteLine(page.Current); // 2
Console.WriteLine(page.Size); // 10
Console.WriteLine(page.TotalElements); // 100
Console.WriteLine(page.TotalPages); // 10
// Null-safe defaults
var unbounded = new Page(size: null, current: null, totalElements: 50, totalPages: 1);
Console.WriteLine(unbounded.Size); // 2147483647 (int.MaxValue)
Console.WriteLine(unbounded.Current); // 0
PagedList<T>
PagedList<T> combines a page of items with auto-calculated Page metadata. Total pages are computed as ⌈totalElements / size⌉.
var items = new List<string> { "alpha", "beta", "gamma" };
var result = new PagedList<string>(
items: items,
totalElements: 10,
page: 2,
size: 3);
// Access items
foreach (var item in result.Items)
Console.WriteLine(item);
// Access pagination metadata
Console.WriteLine(result.Page.Current); // 2
Console.WriteLine(result.Page.Size); // 3
Console.WriteLine(result.Page.TotalElements); // 10
Console.WriteLine(result.Page.TotalPages); // 4 (⌈10/3⌉)
A typical use in a query handler or repository:
public PagedList<OrderDto> GetOrders(int page, int size)
{
var query = _dbContext.Orders.AsQueryable();
var total = query.Count();
var orders = query.Skip(page * size).Take(size).ToList();
return new PagedList<OrderDto>(orders.Select(MapToDto), total, page, size);
}
CurrencyValue
CurrencyValue represents a monetary amount together with its currency. Built-in factory methods cover Euro and US Dollar; custom currencies can be constructed directly.
// Built-in factories
var price = CurrencyValue.Euro(19.99m);
var payment = CurrencyValue.Dollar(9.99m);
Console.WriteLine(price.Value); // 19.99
Console.WriteLine(price.CurrencySymbol); // €
Console.WriteLine(price.CurrencyCode); // EUR
// Custom currency
var pounds = new CurrencyValue(999.99m, "£", "GBP");
// Serialises cleanly with System.Text.Json
var json = JsonSerializer.Serialize(price, new JsonSerializerOptions(JsonSerializerDefaults.Web));
// {"value":19.99,"currencySymbol":"\u20AC","currencyCode":"EUR"}
var restored = JsonSerializer.Deserialize<CurrencyValue>(json,
new JsonSerializerOptions(JsonSerializerDefaults.Web));
Quantity<T>
Quantity<T> is the base for any domain-specific typed quantity. Derive a concrete record to attach semantic meaning to a value/unit pair.
// Define a custom quantity type
public record Celsius(decimal Value) : Quantity<decimal>(Value, "°C");
public record Kilograms(decimal Value) : Quantity<decimal>(Value, "kg");
var temp = new Celsius(36.6m);
var weight = new Kilograms(75m);
Console.WriteLine($"{temp.Value} {temp.Unit}"); // 36.6 °C
Console.WriteLine($"{weight.Value} {weight.Unit}"); // 75 kg
// Record equality is value-based
var a = new Celsius(36.6m);
var b = new Celsius(36.6m);
Console.WriteLine(a == b); // True
// Different types are never equal even with the same value
var c = new Kilograms(36.6m); // not equal to a Celsius
QuantityCount
QuantityCount fixes the unit to "Count" and the value type to int. Derive it for domain-specific integer counters.
// Define domain-specific count types
public record LoginCount(int Value) : QuantityCount(Value);
public record FailedAttempts(int Value) : QuantityCount(Value);
var logins = new LoginCount(42);
var failures = new FailedAttempts(3);
Console.WriteLine(logins.Value); // 42
Console.WriteLine(logins.Unit); // Count
Console.WriteLine(failures.Value); // 3
Console.WriteLine(failures.Unit); // Count
// Each derived type maintains its own identity
Console.WriteLine(logins == failures); // False (different types)
// Serialises with System.Text.Json
var json = JsonSerializer.Serialize(logins, new JsonSerializerOptions(JsonSerializerDefaults.Web));
// {"value":42,"unit":"Count"}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Dosaic.Extensions.Abstractions:
| Package | Downloads |
|---|---|
|
Dosaic.Plugins.Handlers.Abstractions.Cqrs
A plugin-first dotnet framework for rapidly building anything hosted in the web. |
|
|
Dosaic.Plugins.Handlers.Cqrs
A plugin-first dotnet framework for rapidly building anything hosted in the web. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.9 | 0 | 3/13/2026 |
| 1.2.8 | 67 | 3/9/2026 |
| 1.2.7 | 77 | 3/4/2026 |
| 1.2.6 | 91 | 2/19/2026 |
| 1.2.5 | 84 | 2/17/2026 |
| 1.2.4 | 113 | 2/13/2026 |
| 1.2.3 | 96 | 1/27/2026 |
| 1.2.2 | 300 | 12/16/2025 |
| 1.2.1 | 276 | 12/16/2025 |
| 1.2.0 | 436 | 12/11/2025 |
| 1.1.21 | 451 | 12/10/2025 |
| 1.1.20 | 426 | 11/18/2025 |
| 1.1.19 | 300 | 11/11/2025 |
| 1.1.18 | 208 | 10/14/2025 |
| 1.1.17 | 204 | 10/1/2025 |
| 1.1.16 | 192 | 9/25/2025 |
| 1.1.15 | 188 | 9/24/2025 |
| 1.1.14 | 205 | 9/24/2025 |
| 1.1.13 | 209 | 9/24/2025 |
| 1.1.12 | 324 | 9/16/2025 |