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
                    
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="TrickyMottram.UnitConversion.Abstractions" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TrickyMottram.UnitConversion.Abstractions" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TrickyMottram.UnitConversion.Abstractions" />
                    
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 TrickyMottram.UnitConversion.Abstractions --version 1.0.1
                    
#r "nuget: TrickyMottram.UnitConversion.Abstractions, 1.0.1"
                    
#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.
#addin nuget:?package=TrickyMottram.UnitConversion.Abstractions&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TrickyMottram.UnitConversion.Abstractions&version=1.0.1
                    
Install as a Cake Tool

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 converters
  • IUnitRegistry – 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.0.1 146 6/7/2025
1.0.0 61 6/7/2025