コード例 #1
0
        /// <summary>
        /// Division operation, calculates value dividend/divisor with unit that derives from dividend unit
        /// </summary>
        /// <param name="massStream">a dividend (counter) - a value that is being divided</param>
        /// <param name="volumeStream">a divisor (denominator) - a value which dividend is divided by</param>
        public static Density operator /(MassStream massStream, VolumeStream volumeStream)
        {
            // generator : MultiplyAlgebraGenerator.CreateOperator
            // scenario with hint
            // .Is<MassStream, VolumeStream, Density>("/")
            // hint location GetBasicOperatorHints, line 31
            var volumeStreamUnit      = volumeStream.Unit;
            var tmp1                  = volumeStreamUnit.CounterUnit;
            var massStreamUnit        = massStream.Unit;
            var targetRightUnit       = new VolumeStreamUnit(tmp1, massStreamUnit.DenominatorUnit);
            var resultUnit            = new DensityUnit(massStreamUnit.CounterUnit, tmp1);
            var volumeStreamConverted = volumeStream.ConvertTo(targetRightUnit);
            var value                 = massStream.Value / volumeStreamConverted.Value;

            return(new Density(value, resultUnit));
            // scenario F1
        }
コード例 #2
0
        /// <summary>
        /// Multiplication operation
        /// </summary>
        /// <param name="density">left factor (multiplicand)</param>
        /// <param name="volumeStream">rigth factor (multiplier)</param>
        public static MassStream operator *(Density density, VolumeStream volumeStream)
        {
            // generator : MultiplyAlgebraGenerator.CreateOperator
            // scenario with hint
            // .Is<Density, VolumeStream, MassStream>("*")
            // hint location GetBasicOperatorHints, line 31
            var densityUnit           = density.Unit;
            var volumeStreamUnit      = volumeStream.Unit;
            var tmp1                  = volumeStreamUnit.DenominatorUnit;
            var targetRightUnit       = new VolumeStreamUnit(densityUnit.DenominatorUnit, tmp1);
            var resultUnit            = new MassStreamUnit(densityUnit.CounterUnit, tmp1);
            var volumeStreamConverted = volumeStream.ConvertTo(targetRightUnit);
            var value                 = density.Value * volumeStreamConverted.Value;

            return(new MassStream(value, resultUnit));
            // scenario F1
        }
コード例 #3
0
 public bool Equals(VolumeStreamUnit other)
 {
     return(CounterUnit.Equals(other.CounterUnit) && DenominatorUnit.Equals(other.DenominatorUnit));
 }