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

Assign() public static method

Creates a BinaryExpression that represents an assignment operation.
public static Assign ( Expression left, Expression right ) : BinaryExpression
left Expression An to set the property equal to.
right Expression An to set the property equal to.
return BinaryExpression
        public static BinaryExpression Assign(Expression left, Expression right)
        {
            RequiresCanWrite(left, nameof(left));
            RequiresCanRead(right, nameof(right));
            TypeUtils.ValidateType(left.Type, nameof(left));
            TypeUtils.ValidateType(right.Type, nameof(right));
            if (!TypeUtils.AreReferenceAssignable(left.Type, right.Type))
            {
                throw Error.ExpressionTypeDoesNotMatchAssignment(right.Type, left.Type);
            }
            return new AssignBinaryExpression(left, right);
        }

Usage Example

コード例 #1
0
ファイル: Proc.cs プロジェクト: gaybro8777/ironruby
        /// <summary>
        /// From control flow perspective it "calls" the proc.
        /// </summary>
        internal static void SetProcCallRule(
            MetaObjectBuilder /*!*/ metaBuilder,
            Expression /*!*/ procExpression,    // proc object
            Expression /*!*/ selfExpression,    // self passed to the proc
            Expression callingMethodExpression, // RubyLambdaMethodInfo passed to the proc via BlockParam
            CallArguments /*!*/ args            // user arguments passed to the proc
            )
        {
            var bfcVariable    = metaBuilder.GetTemporary(typeof(BlockParam), "#bfc");
            var resultVariable = metaBuilder.GetTemporary(typeof(object), "#result");

            metaBuilder.Result = AstFactory.Block(
                Ast.Assign(bfcVariable,
                           (callingMethodExpression != null) ?
                           Methods.CreateBfcForMethodProcCall.OpCall(
                               AstUtils.Convert(procExpression, typeof(Proc)),
                               callingMethodExpression
                               ) :
                           Methods.CreateBfcForProcCall.OpCall(
                               AstUtils.Convert(procExpression, typeof(Proc))
                               )
                           ),
                Ast.Assign(resultVariable, AstFactory.YieldExpression(
                               args.GetSimpleArgumentExpressions(),
                               args.GetSplattedArgumentExpression(),
                               args.GetRhsArgumentExpression(),
                               bfcVariable,
                               selfExpression
                               )),
                Methods.MethodProcCall.OpCall(bfcVariable, resultVariable),
                resultVariable
                );
        }
All Usage Examples Of System.Linq.Expressions.Expression::Assign
Expression