System.Linq.Expressions.Expression.Divide C# (CSharp) Method

Divide() public static method

Creates a BinaryExpression that represents an arithmetic division operation.
public static Divide ( Expression left, Expression right, MethodInfo method ) : BinaryExpression
left Expression An to set the property equal to.
right Expression An to set the property equal to.
method System.Reflection.MethodInfo A to set the property equal to.
return BinaryExpression
        public static BinaryExpression Divide(Expression left, Expression right, MethodInfo method)
        {
            RequiresCanRead(left, nameof(left));
            RequiresCanRead(right, nameof(right));
            if (method == null)
            {
                if (left.Type == right.Type && left.Type.IsArithmetic())
                {
                    return new SimpleBinaryExpression(ExpressionType.Divide, left, right, left.Type);
                }
                return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Divide, "op_Division", left, right, liftToNull: true);
            }
            return GetMethodBasedBinaryOperator(ExpressionType.Divide, left, right, method, liftToNull: true);
        }

Same methods

Expression::Divide ( Expression left, Expression right ) : BinaryExpression

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Home towards a target location at a fixed speed.
        /// </summary>
        /// <remarks>
        /// Use with StopSampling to home for only a few seconds.
        /// <para>This is primarily for use with non-rotational velocity.
        /// Rotational use creates: contracting spirals (0,90), circle around player [90], expanding spiral (90,180).</para>
        /// </remarks>
        /// <param name="speed">Speed</param>
        /// <param name="location">Target location</param>
        /// <returns></returns>
        public static ExTP VHome(ExBPY speed, ExTP location)
        {
            TExV2 l = new TExV2();

            return(bpi => Ex.Block(new ParameterExpression[] { l },
                                   Ex.Assign(l, location(bpi).Sub(bpi.loc)),
                                   l.Mul(Ex.Divide(speed(bpi), Sqrt(Ex.Add(SqrMag(l), EPS))))
                                   ));
        }
All Usage Examples Of System.Linq.Expressions.Expression::Divide
Expression