TrickyMottram.UnitConversion.Abstractions
1.0.1
dotnet add package TrickyMottram.UnitConversion.Abstractions --version 1.0.1
NuGet\Install-Package TrickyMottram.UnitConversion.Abstractions -Version 1.0.1
<PackageReference Include="TrickyMottram.UnitConversion.Abstractions" Version="1.0.1" />
<PackageVersion Include="TrickyMottram.UnitConversion.Abstractions" Version="1.0.1" />
<PackageReference Include="TrickyMottram.UnitConversion.Abstractions" />
paket add TrickyMottram.UnitConversion.Abstractions --version 1.0.1
#r "nuget: TrickyMottram.UnitConversion.Abstractions, 1.0.1"
#addin nuget:?package=TrickyMottram.UnitConversion.Abstractions&version=1.0.1
#tool nuget:?package=TrickyMottram.UnitConversion.Abstractions&version=1.0.1
TrickyMottram.UnitConversion.Abstractions
Interfaces and foundational contracts for the TrickyMottram Unit Conversion libraries.
This package defines the core abstractions used by the TrickyMottram UnitConversion ecosystem, enabling consistent and extensible unit conversion handling across different measurement domains such as Length, Area, Temperature, Power, Time, and Weight.
✨ Features
IUnitConverter
– standard interface for implementing unit convertersIUnitRegistry
– interface for exposing unit categories and symbols for UI binding or documentation- Consistent API surface for both string-based and strongly typed enum-based conversions
- Supports a hybrid string/enum system to balance flexibility with type safety
- Designed for dependency injection and testability
🔧 Usage Example
Implementing a Custom Converter
public class MyLengthConverter : IUnitConverter
{
public bool CanConvert(string fromUnit, string toUnit) =>
fromUnit == "m" && toUnit == "cm";
public double Convert(double value, string fromUnit, string toUnit) =>
value * 100;
}
Using in an Application
services.AddSingleton<IUnitConverter, MyLengthConverter>();
services.AddSingleton<UnitConversionService>();
public class MyController : ControllerBase
{
private readonly UnitConversionService _service;
public MyController(UnitConversionService service)
{
_service = service;
}
public IActionResult ConvertToCm(double meters)
{
var result = _service.Convert(meters, "m", "cm");
return Ok(result);
}
}
📚 Main Interfaces
TrickyMottram.UnitConversion.Abstractions.Interfaces.IUnitConverter
TrickyMottram.UnitConversion.Abstractions.Interfaces.IUnitRegistry
📦 Package Metadata
- Target Framework:
.NET 8
- License: MIT
- Source: GitHub Repository
- Tags:
unit conversion
,abstractions
,interfaces
✅ Contributing
You’re welcome to contribute converters, registries, or improvements. Please raise an issue or submit a PR on the GitHub repo.
© Tricky Mottram
Product | Versions 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 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. |
-
net8.0
- No dependencies.
NuGet packages (7)
Showing the top 5 NuGet packages that depend on TrickyMottram.UnitConversion.Abstractions:
Package | Downloads |
---|---|
TrickyMottram.UnitConversion.Weight
Provides weight unit conversions for .NET. Part of the TrickyMottram.UnitConversion suite. |
|
TrickyMottram.UnitConversion.Length
Provides length unit conversions for .NET. Part of the TrickyMottram.UnitConversion suite. |
|
TrickyMottram.UnitConversion.Temperature
Provides temperature unit conversions for .NET. Part of the TrickyMottram.UnitConversion suite. |
|
TrickyMottram.UnitConversion.Service
Centralized orchestration service for unit conversion using TrickyMottram converters. |
|
TrickyMottram.UnitConversion.Power
Provides power unit conversions for .NET. Part of the TrickyMottram.UnitConversion suite. |
GitHub repositories
This package is not used by any popular GitHub repositories.