public PressureDrop WithCounterUnit(PressureUnit 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 PressureDrop(oldFactor / newFactor * Value, resultUnit)); }
public static PressureDrop Parse(string value) { // generator : FractionValuesGenerator.Add_Parse if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } var r = CommonParse.Parse(value, typeof(PressureDrop)); var units = Common.SplitUnitNameBySlash(r.UnitName); if (units.Length != 2) { throw new Exception($"{r.UnitName} is not valid PressureDrop unit"); } var counterUnit = new PressureUnit(units[0]); var denominatorUnit = new LengthUnit(units[1]); return(new PressureDrop(r.Value, counterUnit, denominatorUnit)); }
public PressureDrop(decimal value, PressureUnit counterUnit, LengthUnit denominatorUnit) { Value = value; Unit = new PressureDropUnit(counterUnit, denominatorUnit); }