本文整理汇总了C#中PythonContext.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# PythonContext.Convert方法的具体用法?C# PythonContext.Convert怎么用?C# PythonContext.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonContext
的用法示例。
在下文中一共展示了PythonContext.Convert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
/// <summary>
/// Backwards compatible Convert for the old sites that need to flow CodeContext
/// </summary>
public static Expression/*!*/ Convert(Expression/*!*/ codeContext, PythonContext/*!*/ binder, Type/*!*/ type, ConversionResultKind resultKind, Expression/*!*/ target) {
return Ast.Dynamic(
binder.Convert(type, resultKind),
type,
target
);
}
示例2: HashConvertToInt
private static DynamicExpression/*!*/ HashConvertToInt(PythonContext/*!*/ state, Expression/*!*/ expression) {
return DynamicExpression.Dynamic(
state.Convert(
typeof(int),
ConversionResultKind.ExplicitCast
),
typeof(int),
expression
);
}
示例3: MakeRule
public override DynamicMetaObject/*!*/ MakeRule(DynamicMetaObjectBinder/*!*/ metaBinder, PythonContext/*!*/ binder, DynamicMetaObject/*!*/[]/*!*/ args) {
DynamicMetaObject[] tupleArgs = Callable.GetTupleArguments(args);
return Callable.CompleteRuleTarget(metaBinder, tupleArgs, delegate() {
PythonTypeSlot indexSlot;
if (args[1].GetLimitType() != typeof(Slice) && GetTypeAt(1).TryResolveSlot(binder.SharedContext, "__index__", out indexSlot)) {
args[1] = new DynamicMetaObject(
DynamicExpression.Dynamic(
binder.Convert(
typeof(int),
ConversionResultKind.ExplicitCast
),
typeof(int),
DynamicExpression.Dynamic(
binder.InvokeNone,
typeof(object),
AstUtils.Constant(binder.SharedContext),
Binders.Get(
AstUtils.Constant(binder.SharedContext),
binder,
typeof(object),
"__index__",
args[1].Expression
)
)
),
BindingRestrictions.Empty
);
return Callable.CompleteRuleTarget(metaBinder, tupleArgs, null);
}
return null;
});
}
示例4: GetConvertByLengthBody
/// <summary>
/// Used for conversions to bool
/// </summary>
private static Expression/*!*/ GetConvertByLengthBody(PythonContext/*!*/ state, Expression/*!*/ call) {
Assert.NotNull(state, call);
Expression callAsInt = call;
if (call.Type != typeof(int)) {
callAsInt = Ast.Dynamic(
state.Convert(typeof(int), ConversionResultKind.ExplicitCast),
typeof(int),
call
);
}
return Ast.NotEqual(callAsInt, AstUtils.Constant(0));
}