本文整理汇总了C#中DynamicMetaObject.NeedsDeferral方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObject.NeedsDeferral方法的具体用法?C# DynamicMetaObject.NeedsDeferral怎么用?C# DynamicMetaObject.NeedsDeferral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicMetaObject
的用法示例。
在下文中一共展示了DynamicMetaObject.NeedsDeferral方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FallbackDeleteMember
public override DynamicMetaObject FallbackDeleteMember(DynamicMetaObject self, DynamicMetaObject errorSuggestion) {
if (self.NeedsDeferral()) {
return Defer(self);
}
return Context.Binder.DeleteMember(Name, self, new PythonOverloadResolverFactory(_context.Binder, AstUtils.Constant(Context.SharedContext)));
}
示例2: FallbackDeleteMember
public override DynamicMetaObject FallbackDeleteMember(DynamicMetaObject self, DynamicMetaObject errorSuggestion) {
if (self.NeedsDeferral()) {
return Defer(self);
}
return Binder.Binder.DeleteMember(Name, self, AstUtils.Constant(Binder.Context));
}
示例3: FallbackSetMember
public override DynamicMetaObject FallbackSetMember(DynamicMetaObject self, DynamicMetaObject value, DynamicMetaObject onBindingError) {
if (self.NeedsDeferral()) {
return Defer(self, value);
}
#if !SILVERLIGHT
DynamicMetaObject com;
if (System.Dynamic.ComBinder.TryBindSetMember(this, self, value, out com)) {
return com;
}
#endif
return Binder.Binder.SetMember(Name, self, value, Ast.Constant(Binder.Context));
}
示例4: Operation
public static DynamicMetaObject/*!*/ Operation(UnaryOperationBinder/*!*/ operation, DynamicMetaObject arg, DynamicMetaObject errorSuggestion) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Fallback UnaryOperator " + " " + operation.Operation + " " + arg.LimitType.FullName);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, operation.Operation.ToString());
DynamicMetaObject[] args = new[] { arg };
if (arg.NeedsDeferral()) {
return operation.Defer(arg);
}
ValidationInfo valInfo = BindingHelpers.GetValidationInfo(args);
DynamicMetaObject res = null;
Type retType = typeof(object);
switch (operation.Operation) {
case ExpressionType.UnaryPlus:
res = BindingHelpers.AddPythonBoxing(MakeUnaryOperation(operation, arg, "__pos__", errorSuggestion));
break;
case ExpressionType.Negate:
res = BindingHelpers.AddPythonBoxing(MakeUnaryOperation(operation, arg, "__neg__", errorSuggestion));
break;
case ExpressionType.OnesComplement:
res = BindingHelpers.AddPythonBoxing(MakeUnaryOperation(operation, arg, "__invert__", errorSuggestion));
break;
case ExpressionType.Not:
res = MakeUnaryNotOperation(operation, arg, typeof(object), errorSuggestion);
break;
case ExpressionType.IsFalse:
res = MakeUnaryNotOperation(operation, arg, typeof(bool), errorSuggestion);
retType = typeof(bool);
break;
case ExpressionType.IsTrue:
res = PythonProtocol.ConvertToBool(operation, arg);
retType = typeof(bool);
break;
default:
res = TypeError(operation, "unknown operation: " + operation.ToString(), args);
break;
}
return BindingHelpers.AddDynamicTestAndDefer(operation, res, args, valInfo, retType);
}
示例5: Operation
public static DynamicMetaObject Operation(UnaryOperationBinder operation, DynamicMetaObject arg, DynamicMetaObject errorSuggestion)
{
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Fallback UnaryOperator " + " " + operation.Operation + " " + arg.LimitType.FullName);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, operation.Operation.ToString());
DynamicMetaObject[] args = new[] { arg };
if (arg.NeedsDeferral())
return operation.Defer(arg);
ValidationInfo valInfo = BindingHelpers.GetValidationInfo(args);
TotemOperationKind? toOperator = null;
Type retType = typeof(object);
bool box = true;
bool inverse = false;
switch (operation.Operation)
{
case ExpressionType.UnaryPlus: toOperator = TotemOperationKind.Positive; break;
case ExpressionType.Negate: toOperator = TotemOperationKind.Negate; break;
case ExpressionType.OnesComplement: toOperator = TotemOperationKind.OnesComplement; break;
case ExpressionType.Not: toOperator = TotemOperationKind.Not; box = false; break;
case ExpressionType.IsFalse: toOperator = TotemOperationKind.IsFalse; box = false; retType = typeof(bool); break;
case ExpressionType.IsTrue: toOperator = TotemOperationKind.IsFalse; box = false; retType = typeof(bool); inverse = true; break;
}
DynamicMetaObject res = null;
if (toOperator != null)
res = MakeUnaryOperation(operation, args[0], toOperator.Value, errorSuggestion, retType);
else
res = operation.FallbackUnaryOperation(arg);
if (inverse)
{
res = new DynamicMetaObject(
Expression.Condition(
res.Expression,
Utils.Constant(ScriptingRuntimeHelpers.False),
Utils.Constant(ScriptingRuntimeHelpers.True)
),
res.Restrictions
);
}
if (box)
{
res = BindingHelpers.AddTotemBoxing(res);
}
return BindingHelpers.AddDynamicTestAndDefer(operation, res, args, valInfo, retType);
}
示例6: 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(
BinderState.GetCodeContext(action),
BinderState.GetBinderState(action),
typeof(object),
action.Name,
target.Expression
),
BindingRestrictionsHelpers.GetRuntimeTypeRestriction(target)
),
args,
null
),
args,
valInfo
);
}
示例7: Fallback
/// <summary>
/// Fallback - performs the default binding operation if the object isn't recognized
/// as being invokable.
/// </summary>
internal DynamicMetaObject/*!*/ Fallback(Expression codeContext, DynamicMetaObject target, DynamicMetaObject/*!*/[]/*!*/ args) {
if (target.NeedsDeferral()) {
return Defer(args);
}
return PythonProtocol.Call(this, target, args) ??
Binder.Binder.Create(Signature, new ParameterBinderWithCodeContext(Binder.Binder, codeContext), target, args) ??
Binder.Binder.Call(Signature, new ParameterBinderWithCodeContext(Binder.Binder, codeContext), target, args);
}
示例8: GenericCall
/// <summary>
/// Transforms a call into a Python GetMember/Invoke. This isn't quite the correct semantic as
/// we shouldn't be returning Python members (e.g. object.__repr__) to non-Python callers. This
/// can go away as soon as all of the classes implement the full fidelity of the protocol
/// </summary>
internal static DynamicMetaObject/*!*/ GenericCall(InvokeMemberBinder/*!*/ action, DynamicMetaObject target, DynamicMetaObject/*!*/[]/*!*/ args) {
if (target.NeedsDeferral()) {
return action.Defer(args);
}
return new DynamicMetaObject(
Invoke(
BinderState.GetCodeContext(action),
BinderState.GetBinderState(action),
typeof(object),
GetCallSignature(action),
ArrayUtils.Insert(
Binders.Get(
BinderState.GetCodeContext(action),
BinderState.GetBinderState(action),
typeof(object),
action.Name,
target.Expression
),
DynamicUtils.GetExpressions(args)
)
),
BindingRestrictions.Combine(args).Merge(target.Restrict(target.GetLimitType()).Restrictions)
);
}