예제 #1
0
        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;
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
 public LinearForce(decimal value, ForceUnit counterUnit, LengthUnit denominatorUnit)
 {
     Value = value;
     Unit  = new LinearForceUnit(counterUnit, denominatorUnit);
 }
예제 #7
0
 public Torque(decimal value, ForceUnit leftUnit, LengthUnit rightUnit)
 {
     Value = value;
     Unit  = new TorqueUnit(leftUnit, rightUnit);
 }