本文整理汇总了C#中System.Dynamic.InvokeMemberBinder.FallbackInvokeMember方法的典型用法代码示例。如果您正苦于以下问题:C# InvokeMemberBinder.FallbackInvokeMember方法的具体用法?C# InvokeMemberBinder.FallbackInvokeMember怎么用?C# InvokeMemberBinder.FallbackInvokeMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.InvokeMemberBinder
的用法示例。
在下文中一共展示了InvokeMemberBinder.FallbackInvokeMember方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
{
// VbGetBinder calls this method when you read a dynamic property from VB code
var binderDefault = binder.FallbackInvokeMember(this, args);
var expression = Expression.Convert(GetIndexExpression(binder.Name), typeof(object));
var dynamicSuggestion = new DynamicMetaObject(expression, BindingRestrictions.GetTypeRestriction(Expression, LimitType)
.Merge(binderDefault.Restrictions));
return binder.FallbackInvokeMember(this, args, dynamicSuggestion);
}
示例2: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
ContractUtils.RequiresNotNull(binder, "binder");
return binder.FallbackInvokeMember(UnwrapSelf(), args);
}
示例3: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
// Generate a tree like:
//
// {
// object result;
// TryInvokeMember(payload, out result)
// ? result
// : TryGetMember(payload, out result)
// ? FallbackInvoke(result)
// : fallbackResult
// }
//
// Then it calls FallbackInvokeMember with this tree as the
// "error", giving the language the option of using this
// tree or doing .NET binding.
//
Fallback fallback = e => binder.FallbackInvokeMember(this, args, e);
var call = BuildCallMethodWithResult(
"TryInvokeMember",
binder,
DynamicMetaObject.GetExpressions(args),
BuildCallMethodWithResult(
"TryGetMember",
new GetBinderAdapter(binder),
NoArgs,
fallback(null),
(e) => binder.FallbackInvoke(e, args, null)
),
null
);
return fallback(call);
}
示例4: BindInvokeMember
// Because we don't ComboBind over several MOs and operations, and no one
// is falling back to this function with MOs that have no values, we
// don't need to check HasValue. If we did check, and HasValue == False,
// then would defer to new InvokeMemberBinder.Defer().
//
public override DynamicMetaObject BindInvokeMember(
InvokeMemberBinder binder, DynamicMetaObject[] args) {
var flags = BindingFlags.IgnoreCase | BindingFlags.Static |
BindingFlags.Public;
var members = ReflType.GetMember(binder.Name, flags);
if ((members.Length == 1) && (members[0] is PropertyInfo ||
members[0] is FieldInfo)){
// NEED TO TEST, should check for delegate value too
var mem = members[0];
throw new NotImplementedException();
//return new DynamicMetaObject(
// Expression.Dynamic(
// new SymplInvokeBinder(new CallInfo(args.Length)),
// typeof(object),
// args.Select(a => a.Expression).AddFirst(
// Expression.MakeMemberAccess(this.Expression, mem)));
// Don't test for eventinfos since we do nothing with them now.
} else {
// Get MethodInfos with right arg counts.
var mi_mems = members.
Select(m => m as MethodInfo).
Where(m => m is MethodInfo &&
((MethodInfo)m).GetParameters().Length ==
args.Length);
// Get MethodInfos with param types that work for args. This works
// for except for value args that need to pass to reftype params.
// We could detect that to be smarter and then explicitly StrongBox
// the args.
List<MethodInfo> res = new List<MethodInfo>();
foreach (var mem in mi_mems) {
if (RuntimeHelpers.ParametersMatchArguments(
mem.GetParameters(), args)) {
res.Add(mem);
}
}
if (res.Count == 0) {
// Sometimes when binding members on TypeModels the member
// is an instance member since the Type is an instance of Type.
// We fallback to the binder with the Type instance to see if
// it binds. The SymplInvokeMemberBinder does handle this.
var typeMO = RuntimeHelpers.GetRuntimeTypeMoFromModel(this);
var result = binder.FallbackInvokeMember(typeMO, args, null);
return result;
}
// True below means generate an instance restriction on the MO.
// We are only looking at the members defined in this Type instance.
var restrictions = RuntimeHelpers.GetTargetArgsRestrictions(
this, args, true);
// restrictions and conversion must be done consistently.
var callArgs =
RuntimeHelpers.ConvertArguments(
args, res[0].GetParameters());
return new DynamicMetaObject(
RuntimeHelpers.EnsureObjectResult(
Expression.Call(res[0], callArgs)),
restrictions);
// Could hve tried just letting Expr.Call factory do the work,
// but if there is more than one applicable method using just
// assignablefrom, Expr.Call throws. It does not pick a "most
// applicable" method or any method.
}
}
示例5: BindInvokeMember
/// <summary>
/// Performs the binding of the dynamic invoke member operation.
/// </summary>
/// <param name="binder">An instance of the <see cref="InvokeMemberBinder"/> that represents the details of the dynamic operation.</param>
/// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
/// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
public virtual DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
ContractUtils.RequiresNotNull(binder, "binder");
return binder.FallbackInvokeMember(this, args);
}
示例6: BindInvokeMember
public override DynamicMetaObject/*!*/ BindInvokeMember(InvokeMemberBinder/*!*/ binder, params DynamicMetaObject/*!*/[]/*!*/ args) {
var self = (IRubyObject)Value;
return RubyInvokeMemberBinder.TryBind(self.Class.Context, binder, this, args) ?? binder.FallbackInvokeMember(this, args);
}
示例7: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
ContractUtils.RequiresNotNull(binder, "binder");
DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
binder.Name,
binder.IgnoreCase,
binder.FallbackInvokeMember(this, args)
);
//invoke the member value using the language's binder
return AddDynamicTestAndDefer(
binder,
new DynamicMetaObject[] { this },
Value.Class,
null,
binder.FallbackInvoke(memberValue, args, null)
);
}
示例8: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
{
return DynamicTryGetMember(binder.Name,
binder.FallbackInvokeMember(this, args).Expression,
(tmp) => binder.FallbackInvoke(new DynamicMetaObject(tmp, BindingRestrictions.Empty), args, null).Expression
);
}
示例9: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
{
Fallback fallback = e => binder.FallbackInvokeMember(this, args, e);
DynamicMetaObject errorSuggestion = this.BuildCallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), this.BuildCallMethodWithResult("TryGetMember", new GetBinderAdapter(binder), NoArgs, fallback(null), e => binder.FallbackInvoke(e, args, null)), null);
return fallback(errorSuggestion);
}
示例10: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
if (IsOverridden("TryInvokeMember")) {
return CallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), (e) => binder.FallbackInvokeMember(this, args, e));
} else if (IsOverridden("TryGetMember")) {
// Generate a tree like:
//
// {
// object result;
// TryGetMember(payload, out result) ? FallbackInvoke(result) : fallbackResult
// }
//
// Then it calls FallbackInvokeMember with this tree as the
// "error", giving the language the option of using this
// tree or doing .NET binding.
//
return CallMethodWithResult(
"TryGetMember", new GetBinderAdapter(binder), NoArgs,
(e) => binder.FallbackInvokeMember(this, args, e),
(e) => binder.FallbackInvoke(e, args, null)
);
}
return base.BindInvokeMember(binder, args);
}
示例11: BindInvokeMember
/// <summary>
/// Performs the binding of the dynamic invoke member operation.
/// </summary>
/// <param name="binder">
/// An instance of the <see cref="T:System.Dynamic.InvokeMemberBinder" /> that represents the details of the dynamic operation.
/// </param>
/// <param name="args">
/// An array of <see cref="T:System.Dynamic.DynamicMetaObject" /> instances - arguments to the invoke member operation.
/// </param>
/// <returns>
/// The new <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the result of the binding.
/// </returns>
public override DynamicMetaObject BindInvokeMember( InvokeMemberBinder binder, DynamicMetaObject[] args )
{
return ApplyBinding( meta => meta.BindInvokeMember( binder, args ),
( target, errorSuggestion ) =>
binder.FallbackInvokeMember( target, args, errorSuggestion ) );
}
示例12: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
{
return binder.FallbackInvokeMember(UnwrapSelf(), args);
}
示例13: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
if (IsOverridden("TryInvokeMember")) {
return CallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), (e) => binder.FallbackInvokeMember(this, args, e));
}
return base.BindInvokeMember(binder, args);
}
示例14: BindInvokeMember
public override DynamicMetaObject BindInvokeMember( InvokeMemberBinder binder, DynamicMetaObject[] args )
{
return binder.FallbackInvokeMember( _baseMetaObject,
args,
AddTypeRestrictions( _metaObject.BindInvokeMember( binder, args ) ) );
}