本文整理汇总了C#中Microsoft.Scripting.Actions.ActionBinder.MakeCallExpression方法的典型用法代码示例。如果您正苦于以下问题:C# ActionBinder.MakeCallExpression方法的具体用法?C# ActionBinder.MakeCallExpression怎么用?C# ActionBinder.MakeCallExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Actions.ActionBinder
的用法示例。
在下文中一共展示了ActionBinder.MakeCallExpression方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValue
public override DynamicMetaObject GetValue(OverloadResolverFactory resolverFactory, ActionBinder binder, Type type) {
if (!IsStatic || GetIndexParameters().Length > 0) {
// need to bind to a value or parameters to get the value.
return binder.ReturnMemberTracker(type, this);
}
MethodInfo getter = ResolveGetter(binder.PrivateBinding);
if (getter == null || getter.ContainsGenericParameters) {
// no usable getter
return null;
}
if (getter.IsPublic && getter.DeclaringType.IsPublic) {
return binder.MakeCallExpression(resolverFactory, getter);
}
// private binding is just a call to the getter method...
return MemberTracker.FromMemberInfo(getter).Call(resolverFactory, binder);
}
示例2: Call
internal override System.Linq.Expressions.Expression Call(Expression context, ActionBinder binder, params Expression[] arguments) {
if (Method.IsPublic && Method.DeclaringType.IsVisible) {
// TODO: Need to use MethodBinder in here to make this right.
return binder.MakeCallExpression(context, Method, arguments);
}
//methodInfo.Invoke(obj, object[] params)
if (Method.IsStatic) {
return Ast.Convert(
Ast.Call(
Ast.Constant(Method),
typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
Ast.Constant(null),
AstUtils.NewArrayHelper(typeof(object), arguments)
),
Method.ReturnType);
}
if (arguments.Length == 0) throw Error.NoInstanceForCall();
return Ast.Convert(
Ast.Call(
Ast.Constant(Method),
typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
arguments[0],
AstUtils.NewArrayHelper(typeof(object), ArrayUtils.RemoveFirst(arguments))
),
Method.ReturnType);
}
示例3: Call
internal override DynamicMetaObject Call(OverloadResolverFactory resolverFactory, ActionBinder binder, params DynamicMetaObject[] arguments) {
if (Method.IsPublic && Method.DeclaringType.IsVisible) {
return binder.MakeCallExpression(resolverFactory, Method, arguments);
}
//methodInfo.Invoke(obj, object[] params)
if (Method.IsStatic) {
return new DynamicMetaObject(
Ast.Convert(
Ast.Call(
AstUtils.Constant(Method),
typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
AstUtils.Constant(null),
AstUtils.NewArrayHelper(typeof(object), ArrayUtils.ConvertAll(arguments, x => x.Expression))
),
Method.ReturnType
),
BindingRestrictions.Empty
)
;
}
if (arguments.Length == 0) throw Error.NoInstanceForCall();
return new DynamicMetaObject(
Ast.Convert(
Ast.Call(
AstUtils.Constant(Method),
typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
arguments[0].Expression,
AstUtils.NewArrayHelper(typeof(object), ArrayUtils.ConvertAll(ArrayUtils.RemoveFirst(arguments), x => x.Expression))
),
Method.ReturnType
),
BindingRestrictions.Empty
);
}
示例4: Call
public override Microsoft.Scripting.Ast.Expression Call(ActionBinder binder, params Expression[] arguments) {
if (Method.IsPublic && Method.DeclaringType.IsVisible) {
// TODO: Need to use MethodBinder in here to make this right.
return binder.MakeCallExpression(Method, arguments);
}
//methodInfo.Invoke(obj, object[] params)
if (Method.IsStatic) {
return Ast.Convert(
Ast.Call(
Ast.RuntimeConstant(Method),
typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
Ast.Null(),
Ast.NewArrayHelper(typeof(object[]), arguments)),
Method.ReturnType);
}
if (arguments.Length == 0) throw new InvalidOperationException("no instance for call");
return Ast.Convert(
Ast.Call(
Ast.RuntimeConstant(Method),
typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
arguments[0],
Ast.NewArrayHelper(typeof(object[]), ArrayUtils.RemoveFirst(arguments))),
Method.ReturnType);
}
示例5: GetBoundValue
protected internal override Expression GetBoundValue(Expression context, ActionBinder binder, Type type, Expression instance) {
if (instance != null && IsStatic) {
return null;
}
if (GetIndexParameters().Length > 0) {
// need to bind to a value or parameters to get the value.
return binder.ReturnMemberTracker(type, BindToInstance(instance));
}
MethodInfo getter = GetGetMethod(true);
if (getter == null || getter.ContainsGenericParameters) {
// no usable getter
return null;
}
getter = CompilerHelpers.TryGetCallableMethod(getter);
if (binder.PrivateBinding || CompilerHelpers.IsVisible(getter)) {
return binder.MakeCallExpression(context, getter, instance);
}
// private binding is just a call to the getter method...
return DefaultBinder.MakeError(((DefaultBinder)binder).MakeNonPublicMemberGetError(context, this, type, instance));
}