public UnitGraphTests() { AdHocConfig.Use(uc => { uc.SetMeasurePrecision(4); uc.Unit(U.Meter).IsPhysicalUnit(U._LENGTH); uc.Unit(U.Centimeter).IsPhysicalUnit(U._LENGTH); uc.Unit(U.Inch).IsPhysicalUnit(U._LENGTH); uc.Unit(U.Second).IsPhysicalUnit(U._TIME); }); ug = new UnitGraph(); var n1 = ug.AddUnit(U.Inch); var n2 = ug.AddUnit(U.Centimeter); var n3 = ug.AddUnit(U.Meter); ug.AddConversion(n1, n2, v => v * 2.54m, v => v * 0.393700787m); ug.AddConversion(n2, n3, v => v * 0.01m, v => v * 100); }
public ComplexUnitGraphTests() { AdHocConfig.Use(uc => { uc.SetMeasurePrecision(4); uc.Unit(U.Meter).IsPhysicalUnit(U._LENGTH); uc.Unit(U.Second).IsPhysicalUnit(U._TIME); uc.Unit(U.Kilogram) .IsPhysicalUnit(U._MASS) .EquivalentTo(U.Joule*U.Second.Squared()/U.Meter.Squared()); uc.Unit(U.Joule) .IsPhysicalUnit((U._MASS*U._LENGTH.Squared())/U._TIME.Squared()) .EquivalentTo(U.Kilogram*U.Meter.Squared()/U.Second.Squared()); }); ug = new UnitGraph(); var n1 = ug.AddUnit(U.Kilogram); var n2 = ug.AddUnit(U.Joule); ug.AddMeasurementConversion(n1, n2, m => m * PhysicalConstants.EnergyMassFactor, m => m / PhysicalConstants.EnergyMassFactor); }
public ConversionTracker(UnitGraph unitGraph) { this.unitGraph = unitGraph; }