Afrowave.SharedTools.Models 1.4.0-alpha

This is a prerelease version of Afrowave.SharedTools.Models.
dotnet add package Afrowave.SharedTools.Models --version 1.4.0-alpha
                    
NuGet\Install-Package Afrowave.SharedTools.Models -Version 1.4.0-alpha
                    
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="Afrowave.SharedTools.Models" Version="1.4.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Afrowave.SharedTools.Models" Version="1.4.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Afrowave.SharedTools.Models" />
                    
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 Afrowave.SharedTools.Models --version 1.4.0-alpha
                    
#r "nuget: Afrowave.SharedTools.Models, 1.4.0-alpha"
                    
#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 Afrowave.SharedTools.Models@1.4.0-alpha
                    
#: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=Afrowave.SharedTools.Models&version=1.4.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Afrowave.SharedTools.Models&version=1.4.0-alpha&prerelease
                    
Install as a Cake Tool

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 wrappers
  • Results/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 Success
  • bool Warning
  • string 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 Success
  • bool Warning
  • string Message
  • T Data
  • bool HasData – indicates whether Data was 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 identifier
  • DateTimeOffset TimestampUtc
  • string Action – operation identifier
  • string? Sender
  • string? Target
  • Dictionary<string,string>? Meta

Generic-only properties

  • T Body
  • bool 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 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. 
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 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.

Version Downloads Last Updated
1.4.0-alpha 217 12/12/2025
0.0.31 311 10/7/2025
0.0.30 205 10/6/2025
0.0.21 216 10/5/2025
0.0.2 203 10/4/2025
0.0.1 182 10/4/2025

Correction - added missing class member for Language (rtl). Added support for Countries and Languages tools in I18N packgages