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

MakeDynamic() public static method

Creates a DynamicExpression that represents a dynamic operation bound by the provided CallSiteBinder and two arguments.
public static MakeDynamic ( Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1 ) : DynamicExpression
delegateType Type The type of the delegate used by the .
binder CallSiteBinder The runtime binder for the dynamic operation.
arg0 Expression The first argument to the dynamic operation.
arg1 Expression The second argument to the dynamic operation.
return DynamicExpression
        public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1)
        {
            ContractUtils.RequiresNotNull(delegateType, nameof(delegateType));
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            if (!delegateType.IsSubclassOf(typeof(MulticastDelegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();

            var method = GetValidMethodForDynamic(delegateType);
            var parameters = method.GetParametersCached();

            ValidateArgumentCount(method, ExpressionType.Dynamic, 3, parameters);
            ValidateDynamicArgument(arg0, nameof(arg0));
            ValidateOneArgument(method, ExpressionType.Dynamic, arg0, parameters[1], nameof(delegateType), nameof(arg0));
            ValidateDynamicArgument(arg1, nameof(arg1));
            ValidateOneArgument(method, ExpressionType.Dynamic, arg1, parameters[2], nameof(delegateType), nameof(arg1));

            return DynamicExpression.Make(method.GetReturnType(), delegateType, binder, arg0, arg1);
        }

Same methods

Expression::MakeDynamic ( CallSiteBinder binder, Type returnType, ReadOnlyCollection args ) : DynamicExpression
Expression::MakeDynamic ( Type delegateType, CallSiteBinder binder ) : DynamicExpression
Expression::MakeDynamic ( Type delegateType, CallSiteBinder binder, Expression arg0 ) : DynamicExpression
Expression::MakeDynamic ( Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2 ) : DynamicExpression
Expression::MakeDynamic ( Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3 ) : DynamicExpression
Expression::MakeDynamic ( Type delegateType, CallSiteBinder binder, IEnumerable arguments ) : DynamicExpression

Usage Example

Ejemplo n.º 1
0
 public DynamicExpression Update(IEnumerable <Expression> arguments)
 {
     if (arguments == this.Arguments)
     {
         return(this);
     }
     return(Expression.MakeDynamic(this.DelegateType, this.Binder, arguments));
 }
All Usage Examples Of System.Linq.Expressions.Expression::MakeDynamic
Expression