Skip to content

Add API to for From UnitSystem #1271

Closed
Closed
@holmes-mike

Description

@holmes-mike

I am looking for an API to convert from one unit system to another. I expect I have not found the correct API?

What I would expect to see is:

var value = 1.0;
var inputSystem = new UnitSystem(new BaseUnits(....));
var siValue = Length.From(value, inputSystem).As(UnitSystem.SI);

I'm not entirely sure what the purpose of the nullable unit types for a given system are. My current code looks like:

var value = 1.0;
var inputSystem = new UnitSystem(new BaseUnits(....));
va siValue = Length.From(value, inputSystem.BaseUnits.Length!.Value).As(UnitSystem.SI);

however this does not extend so well to things like Pressure.

var value = 1.0;
var inputSystem = new UnitSystem(new BaseUnits(....));
va siValue = Pressure.From(value, ???).As(UnitSystem.SI);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions