Exemple #1
0
        /// <summary>
        /// Creates the derived unit.
        /// </summary>
        /// <param name="baseReductionResult">The base reduction result.</param>
        /// <param name="reductionResult">The reduction result.</param>
        /// <returns>A new <see cref="DerivedUnit" /> for the <see cref="IReductionResult" />.</returns>
        public DerivedUnit CreateDerivedUnit(IReductionResult baseReductionResult, IReductionResult reductionResult)
        {
            DerivedUnit derivedUnit;

            if (this.derivedUnitRegistry.TryGetUnit(baseReductionResult.FlatRepresentation, out derivedUnit))
            {
                return(derivedUnit);
            }

            var expression     = reductionResult.GetReducedExpression(this.expressionRewriter);
            var unitExpression = expression as UnitExpression;

            if (unitExpression != null)
            {
                derivedUnit = unitExpression.Unit as DerivedUnit;
                if (derivedUnit != null)
                {
                    return(derivedUnit);
                }
            }

            return(new DerivedUnit(null, expression));
        }
        /// <summary>
        /// Creates the derived unit.
        /// </summary>
        /// <param name="baseReductionResult">The base reduction result.</param>
        /// <param name="reductionResult">The reduction result.</param>
        /// <returns>A new <see cref="DerivedUnit" /> for the <see cref="IReductionResult" />.</returns>
        public DerivedUnit CreateDerivedUnit(IReductionResult baseReductionResult, IReductionResult reductionResult)
        {
            DerivedUnit derivedUnit;
            if (this.derivedUnitRegistry.TryGetUnit(baseReductionResult.FlatRepresentation, out derivedUnit))
            {
                return derivedUnit;
            }

            var expression = reductionResult.GetReducedExpression(this.expressionRewriter);
            var unitExpression = expression as UnitExpression;
            if (unitExpression != null)
            {
                derivedUnit = unitExpression.Unit as DerivedUnit;
                if (derivedUnit != null)
                {
                    return derivedUnit;
                }
            }

            return new DerivedUnit(null, expression);
        }
Exemple #3
0
 /// <summary>
 /// Creates the derived unit.
 /// </summary>
 /// <param name="reductionResult">The reduction result.</param>
 /// <returns>A new <see cref="DerivedUnit" />.</returns>
 public DerivedUnit CreateDerivedUnit(IReductionResult reductionResult)
 {
     return(this.CreateDerivedUnit(reductionResult, reductionResult));
 }
 /// <summary>
 /// Creates the derived unit.
 /// </summary>
 /// <param name="reductionResult">The reduction result.</param>
 /// <returns>A new <see cref="DerivedUnit" />.</returns>
 public DerivedUnit CreateDerivedUnit(IReductionResult reductionResult)
 {
     return this.CreateDerivedUnit(reductionResult, reductionResult);
 }