本文整理汇总了C#中DynamicMetaObjectBinder.SupportsLightThrow方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObjectBinder.SupportsLightThrow方法的具体用法?C# DynamicMetaObjectBinder.SupportsLightThrow怎么用?C# DynamicMetaObjectBinder.SupportsLightThrow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicMetaObjectBinder
的用法示例。
在下文中一共展示了DynamicMetaObjectBinder.SupportsLightThrow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeWorker
private DynamicMetaObject InvokeWorker(DynamicMetaObjectBinder/*!*/ callAction, DynamicMetaObject/*!*/[] args) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Method Invoke " + args.Length);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "Method");
CallSignature signature = BindingHelpers.GetCallSignature(callAction);
DynamicMetaObject self = Restrict(typeof(Method));
BindingRestrictions restrictions = self.Restrictions;
DynamicMetaObject func = GetMetaFunction(self);
DynamicMetaObject call;
if (Value.im_self == null) {
// restrict to null self (Method is immutable so this is an invariant test)
restrictions = restrictions.Merge(
BindingRestrictions.GetExpressionRestriction(
Ast.Equal(
GetSelfExpression(self),
AstUtils.Constant(null)
)
)
);
if (args.Length == 0) {
// this is an error, we pass null which will throw the normal error
call = new DynamicMetaObject(
Ast.Call(
typeof(PythonOps).GetMethod("MethodCheckSelf"),
PythonContext.GetCodeContext(callAction),
self.Expression,
AstUtils.Constant(null)
),
restrictions
);
} else {
// this may or may not be an error
call = new DynamicMetaObject(
Ast.Block(
MakeCheckSelf(callAction, signature, args),
Ast.Dynamic(
PythonContext.GetPythonContext(callAction).Invoke(
BindingHelpers.GetCallSignature(callAction)
).GetLightExceptionBinder(callAction.SupportsLightThrow()),
typeof(object),
ArrayUtils.Insert(PythonContext.GetCodeContext(callAction), DynamicUtils.GetExpressions(ArrayUtils.Insert(func, args)))
)
),
BindingRestrictions.Empty
);
/*call = func.Invoke(callAction, ArrayUtils.Insert(func, args));
call = new MetaObject(
Ast.Comma(
Ast.Call(
typeof(PythonOps).GetMethod("MethodCheckSelf"),
self.Expression,
args[0].Expression
),
call.Expression
),
call.Restrictions
);*/
}
} else {
// restrict to non-null self (Method is immutable so this is an invariant test)
restrictions = restrictions.Merge(
BindingRestrictions.GetExpressionRestriction(
Ast.NotEqual(
GetSelfExpression(self),
AstUtils.Constant(null)
)
)
);
DynamicMetaObject im_self = GetMetaSelf(self);
DynamicMetaObject[] newArgs = ArrayUtils.Insert(func, im_self, args);
CallSignature newSig = new CallSignature(ArrayUtils.Insert(new Argument(ArgumentType.Simple), signature.GetArgumentInfos()));
call = new DynamicMetaObject(
Ast.Dynamic(
PythonContext.GetPythonContext(callAction).Invoke(
newSig
).GetLightExceptionBinder(callAction.SupportsLightThrow()),
typeof(object),
ArrayUtils.Insert(PythonContext.GetCodeContext(callAction), DynamicUtils.GetExpressions(newArgs))
),
BindingRestrictions.Empty
);
/*
call = func.Invoke(
new CallBinder(
PythonContext.GetBinderState(callAction),
newSig
),
newArgs
);*/
}
if (call.HasValue) {
return new DynamicMetaObject(
//.........这里部分代码省略.........