Afrowave.SharedTools.Models
1.4.0-alpha
dotnet add package Afrowave.SharedTools.Models --version 1.4.0-alpha
NuGet\Install-Package Afrowave.SharedTools.Models -Version 1.4.0-alpha
<PackageReference Include="Afrowave.SharedTools.Models" Version="1.4.0-alpha" />
<PackageVersion Include="Afrowave.SharedTools.Models" Version="1.4.0-alpha" />
<PackageReference Include="Afrowave.SharedTools.Models" />
paket add Afrowave.SharedTools.Models --version 1.4.0-alpha
#r "nuget: Afrowave.SharedTools.Models, 1.4.0-alpha"
#:package Afrowave.SharedTools.Models@1.4.0-alpha
#addin nuget:?package=Afrowave.SharedTools.Models&version=1.4.0-alpha&prerelease
#tool nuget:?package=Afrowave.SharedTools.Models&version=1.4.0-alpha&prerelease
Afrowave.SharedTools.Models
This module contains foundational, framework-agnostic models used across the Afrowave ecosystem.
Its primary goal is to provide simple, consistent, and developer-friendly primitives for:
- method results
- data responses
- request/command envelopes
- metadata transport
All models are compatible with .NET Standard 2.1 and are designed to scale from small utilities to distributed, plugin-based systems.
📦 Contents
Results
Results/Result.cs– Boolean result wrapper (no payload)Results/Response.cs– Generic and non-generic response wrappersResults/Unit.cs– Explicit "no data" value for generic responses
Communication
Communication/Request.cs– Request and Request<T> envelopes
Other domains (unchanged)
- LibreTranslate models (settings, requests, responses)
- Localization models (Country, Language)
✅ Result
Result represents the outcome of an operation without returning data.
var result = Result.Ok("Operation succeeded");
if (!result.Success)
{
Console.WriteLine(result.Message);
}
Members
bool Successbool Warningstring Message
Factory methods
Result.Ok()Result.Ok(string message)Result.OkWithWarning(string message)Result.Fail()Result.Fail(string message)Result.Fail(Exception ex)
Result and Response intentionally share the same factory syntax.
✅ Response / Response<T>
Response and Response<T> represent standardized operation responses with optional payload.
Non-generic Response
Use when no data needs to be returned:
return Response.Ok("Saved successfully");
return Response.Fail("Invalid input");
Generic Response<T>
Use when an operation may return data:
var response = Response<User>.Ok(user, "User loaded");
if (response.Success && response.HasData)
{
Display(response.Data);
}
Key properties
bool Successbool Warningstring MessageT Databool HasData– indicates whetherDatawas explicitly provided
Factory methods (unified)
Ok()Ok(string message)Ok(T data)Ok(T data, string message)OkWithWarning(string message)OkWithWarning(T data, string message)Fail()Fail(string message)Fail(Exception ex)
Backward-compatible methods
Existing APIs remain supported:
SuccessResponse(T data, string message)SuccessWithWarning(T data, string warningMessage)EmptySuccess()
🧩 Unit
Unit represents an explicit "no payload" value for generic responses.
return Response<Unit>.Ok();
return Response<Unit>.Fail("Not allowed");
This avoids forcing placeholder values when T is not meaningful.
📩 Request / Request<T>
Request models provide a lightweight, framework-independent command/query envelope. They are suitable for:
- API calls
- plugin dispatchers
- internal messaging
- background workers
Request (non-generic)
var request = Request.Create("localization.resolve");
Request<T> (with payload)
var request = Request<string>.Create(
action: "docs.translate",
body: "Hello world",
sender: "Client",
target: "Translator"
);
Common properties
Guid Id– correlation identifierDateTimeOffset TimestampUtcstring Action– operation identifierstring? Senderstring? TargetDictionary<string,string>? Meta
Generic-only properties
T Bodybool HasBody
Factory methods
Request.Create(...)Request<T>.Create(action, body, ...)Request<T>.CreateNoBody(...)
🌍 LibreTranslate Models
Models for integration with the LibreTranslate API (settings, requests, responses). These remain unchanged and coexist with the shared Result / Response infrastructure.
🌐 Localization Models
Metadata models for countries and languages used in localization, UI selection, and formatting.
🧭 Design principles
- ✔ .NET Standard 2.1 compatible
- ✔ No framework dependencies
- ✔ Nullable-friendly without forcing newer runtimes
- ✔ Unified syntax across Result / Response / Request
- ✔ Safe defaults, explicit intent (
HasData,HasBody)
✍️ This documentation is part of the Afrowave multilingual docs system.
Translations are generated and maintained via LangHub.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http (>= 2.3.0)
- System.Text.Json (>= 10.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Afrowave.SharedTools.Models:
| Package | Downloads |
|---|---|
|
Afrowave.SharedTools.Api
API abstractions and helpers for Afrowave.SharedTools. Provides standardized interfaces and wrappers for integration.Added multipart forms |
|
|
Afrowave.SharedTools.IO
Universal IO toolkit. |
|
|
Afrowave.SharedTools.Ftp
Universal FTP toolkit. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Correction - added missing class member for Language (rtl). Added support for Countries and Languages tools in I18N packgages