public Pressure(decimal value, ForceUnit force, AreaUnit area) { var areaValue = new Area(1, area) .ConvertTo(AreaUnits.SquareMeter); var forceValue = new Force(value, force) .ConvertTo(ForceUnits.Newton); Value = forceValue.Value / areaValue.Value; Unit = PressureUnits.Pascal; }
public LinearForce WithCounterUnit(ForceUnit newUnit) { // generator : FractionValuesGenerator.Add_WithCounterUnit var oldUnit = Unit.CounterUnit; if (oldUnit == newUnit) { return(this); } var oldFactor = GlobalUnitRegistry.Factors.GetThrow(oldUnit); var newFactor = GlobalUnitRegistry.Factors.GetThrow(newUnit); var resultUnit = Unit.WithCounterUnit(newUnit); return(new LinearForce(oldFactor / newFactor * Value, resultUnit)); }
public Torque WithLeftUnit(ForceUnit newUnit) { // generator : ProductValuesGenerator.Add_WithCounterUnit var oldUnit = Unit.LeftUnit; if (oldUnit == newUnit) { return(this); } var oldFactor = GlobalUnitRegistry.Factors.GetThrow(oldUnit); var newFactor = GlobalUnitRegistry.Factors.GetThrow(newUnit); var resultUnit = Unit.WithLeftUnit(newUnit); return(new Torque(oldFactor / newFactor * Value, resultUnit)); }
public static LinearForce Parse(string value) { // generator : FractionValuesGenerator.Add_Parse if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } var r = CommonParse.Parse(value, typeof(LinearForce)); var units = Common.SplitUnitNameBySlash(r.UnitName); if (units.Length != 2) { throw new Exception($"{r.UnitName} is not valid LinearForce unit"); } var counterUnit = new ForceUnit(units[0]); var denominatorUnit = new LengthUnit(units[1]); return(new LinearForce(r.Value, counterUnit, denominatorUnit)); }
public static Torque Parse(string value) { // generator : ProductValuesGenerator.Add_Parse if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } var r = CommonParse.Parse(value, typeof(Torque)); var units = Common.SplitUnitNameByTimesSign(r.UnitName); if (units.Length != 2) { throw new Exception($"{r.UnitName} is not valid Torque unit"); } var counterUnit = new ForceUnit(units[0]); var denominatorUnit = new LengthUnit(units[1]); return(new Torque(r.Value, counterUnit, denominatorUnit)); }
public LinearForce(decimal value, ForceUnit counterUnit, LengthUnit denominatorUnit) { Value = value; Unit = new LinearForceUnit(counterUnit, denominatorUnit); }
public Torque(decimal value, ForceUnit leftUnit, LengthUnit rightUnit) { Value = value; Unit = new TorqueUnit(leftUnit, rightUnit); }