本文整理汇总了C#中System.Dynamic.InvokeMemberBinder.FallbackInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# InvokeMemberBinder.FallbackInvoke方法的具体用法?C# InvokeMemberBinder.FallbackInvoke怎么用?C# InvokeMemberBinder.FallbackInvoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.InvokeMemberBinder
的用法示例。
在下文中一共展示了InvokeMemberBinder.FallbackInvoke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
var result = TryBindGetMember(binder.Name);
if (result != null) {
return binder.FallbackInvoke(result, args, null);
}
return base.BindInvokeMember(binder, args);
}
示例2: 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);
}
示例3: GenericInvokeMember
/// <summary>
/// Transforms an invoke member into a Python GetMember/Invoke. The caller should
/// verify that the given attribute is not resolved against a normal .NET class
/// before calling this. If it is a normal .NET member then a fallback InvokeMember
/// is preferred.
/// </summary>
internal static DynamicMetaObject/*!*/ GenericInvokeMember(InvokeMemberBinder/*!*/ action, ValidationInfo valInfo, DynamicMetaObject target, DynamicMetaObject/*!*/[]/*!*/ args) {
if (target.NeedsDeferral()) {
return action.Defer(args);
}
return AddDynamicTestAndDefer(action,
action.FallbackInvoke(
new DynamicMetaObject(
Binders.Get(
PythonContext.GetCodeContext(action),
PythonContext.GetPythonContext(action),
typeof(object),
action.Name,
target.Expression
),
BindingRestrictionsHelpers.GetRuntimeTypeRestriction(target)
),
args,
null
),
args,
valInfo
);
}
示例4: 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)
);
}
示例5: 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
);
}
示例6: 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);
}
示例7: 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);
}
示例8: BindInvokeMember
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
{
var expression = Expr.Dynamic(new LuaGetMemberBinder(binder.Name), typeof(object), Expression);
return binder.FallbackInvoke(new DynamicMetaObject(expression, Restrictions), args, null);
}