Пример #1
0
        private static double _VolumeInches3ToOtherUS(double value, Unit toUnit)
        {
            Debug.Assert((Unit.CubicFoot == toUnit) || (Unit.CubicYard == toUnit));
            double convertedValue = VolumeConvertor.Inches3ToFoots3(value); // [ft3]

            if (Unit.CubicYard == toUnit)
            {
                convertedValue = VolumeConvertor.Foots3ToYards3(convertedValue); // [yd3]
            }
            return(convertedValue);
        }
Пример #2
0
        private static double _ConvertVolume(double value, Unit fromUnit, Unit toUnit)
        {
            if (fromUnit == toUnit)
            {
                return(value);
            }

            Debug.Assert((Unit.CubicFoot == toUnit) || (Unit.CubicInch == toUnit) ||
                         (Unit.CubicYard == toUnit) || (Unit.CubicMeter == toUnit));

            double convertedValue = value;

            if (Unit.CubicInch == fromUnit)                                                             // [in3]
            {
                convertedValue = (Unit.CubicMeter == toUnit)? VolumeConvertor.Inches3ToMeters3(value) : // [m3]
                                 _VolumeInches3ToOtherUS(value, toUnit);                                // [ft3], [yd3]
            }

            else if (Unit.CubicFoot == fromUnit)                                                     // [ft3]
            {
                convertedValue = (Unit.CubicYard == toUnit)? VolumeConvertor.Foots3ToYards3(value) : // [yd3]
                                 _VolumeFoots3ToOther(value, toUnit);                                // [in3], [m3]
            }

            else if (Unit.CubicYard == fromUnit)                        // [yd3]
            {
                convertedValue = VolumeConvertor.Yards3ToFoots3(value); // [ft3]
                if (Unit.CubicFoot != toUnit)
                {
                    convertedValue = _VolumeFoots3ToOther(convertedValue, toUnit); // [in3], [m3]
                }
            }

            else if (Unit.CubicMeter == fromUnit)                         // [m3]
            {
                convertedValue = VolumeConvertor.Meters3ToInches3(value); // [in3]
                if (Unit.CubicInch != toUnit)
                {
                    convertedValue = _VolumeInches3ToOtherUS(convertedValue, toUnit); // [ft3], [yd3]
                }
            }

            return(convertedValue);
        }