Exemple #1
0
        public static string GetUnitSymbol(ForceUnits units)
        {
            switch (units)
            {
            case ForceUnits.Newtons:
                return("N");

            case ForceUnits.PoundForce:
                return("lbf");

            default:
                throw new ArgumentOutOfRangeException(nameof(units), units, null);
            }
        }
Exemple #2
0
        public double GetValueInUnits(ForceUnits units)
        {
            switch (units)
            {
            case ForceUnits.Newtons:
                return(InNewtons);

            case ForceUnits.PoundForce:
                return(InPoundForce);

            default:
                throw new ArgumentOutOfRangeException(nameof(units), units, null);
            }
        }
    public static double Unit(
        [ExcelArgument("Value")] double value,
        [ExcelArgument("Previous unit", Name = "previous_Unit")] string _prevUnit,
        [ExcelArgument("New unit", Name = "new_Unit")] string _newUnit)
    {
        double prevUnit; double newUnit;

        if (ForceUnits.TryGetValue(_prevUnit, out prevUnit) &&
            ForceUnits.TryGetValue(_newUnit, out newUnit))
        {
            return(value * newUnit / prevUnit);
        }
        else if (LengthUnits.TryGetValue(_prevUnit, out prevUnit) &&
                 LengthUnits.TryGetValue(_newUnit, out newUnit))
        {
            return(value * newUnit / prevUnit);
        }
        else if (AreaUnits.TryGetValue(_prevUnit, out prevUnit) &&
                 AreaUnits.TryGetValue(_newUnit, out newUnit))
        {
            return(value * newUnit / prevUnit);
        }
        else if (MomentUnits.TryGetValue(_prevUnit, out prevUnit) &&
                 MomentUnits.TryGetValue(_newUnit, out newUnit))
        {
            return(value * newUnit / prevUnit);
        }
        else if (PressureUnits.TryGetValue(_prevUnit, out prevUnit) &&
                 PressureUnits.TryGetValue(_newUnit, out newUnit))
        {
            return(value * newUnit / prevUnit);
        }
        else
        {
            return(double.NaN);
        }
    }
Exemple #4
0
 public Force(ForceUnits currentUnit) : base(currentUnit)
 {
 }