TrickyMottram.UnitConversion.Length
1.0.1
dotnet add package TrickyMottram.UnitConversion.Length --version 1.0.1
NuGet\Install-Package TrickyMottram.UnitConversion.Length -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.Length" 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.Length" Version="1.0.1" />
<PackageReference Include="TrickyMottram.UnitConversion.Length" />
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.Length --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TrickyMottram.UnitConversion.Length, 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.Length&version=1.0.1
#tool nuget:?package=TrickyMottram.UnitConversion.Length&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TrickyMottram.UnitConversion.Length
Length unit conversion implementation for the TrickyMottram Unit Conversion libraries.
This package provides an implementation of IUnitConverter
and IUnitRegistry
for handling common length and distance conversions using metric, imperial, and nautical units. It is part of the TrickyMottram.UnitConversion ecosystem.
✨ Features
- Converts between all common length units (e.g. millimeter, inch, foot, mile, nautical mile)
- Supports both string-based and strongly typed enum-based APIs
- Fully compatible with the
UnitConversionService
- Designed for testability, extensibility, and structured logging
- Provides a unit registry for easy UI population or discovery
🔧 Usage Example
Add to Dependency Injection
services.AddSingleton<IUnitConverter, LengthConverter>();
services.AddSingleton<IUnitRegistry, LengthUnitRegistry>();
Convert via UnitConversionService
public class LengthController : ControllerBase
{
private readonly UnitConversionService _service;
public LengthController(UnitConversionService service)
{
_service = service;
}
[HttpGet]
public IActionResult ConvertLength(double value, string from, string to)
{
var result = _service.Convert(value, from, to);
return Ok(result);
}
}
Strongly Typed Conversion
double km = new LengthConverter(logger)
.Convert(1000, LengthUnit.Meter, LengthUnit.Kilometer); // 1.0
📚 Main Types
TrickyMottram.UnitConversion.Length.LengthConverter
TrickyMottram.UnitConversion.Length.Registry.LengthUnitRegistry
TrickyMottram.UnitConversion.Length.Enums.LengthUnit
TrickyMottram.UnitConversion.Length.Extensions.LengthUnitExtensions
📦 Package Metadata
- Target Framework:
.NET 8
- License: MIT
- Source: GitHub Repository
- Tags:
unit conversion
,length
,measurement
,dotnet
✅ Contributing
Suggestions and improvements for additional length units, precision handling, or international standards are welcome via PR or GitHub issues.
© 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- TrickyMottram.UnitConversion.Abstractions (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.1 | 107 | 6/7/2025 |