当前位置: 首页>>代码示例>>C#>>正文


C# PythonContext.Invoke方法代码示例

本文整理汇总了C#中PythonContext.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# PythonContext.Invoke方法的具体用法?C# PythonContext.Invoke怎么用?C# PythonContext.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PythonContext的用法示例。


在下文中一共展示了PythonContext.Invoke方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeSlotCallWorker

        private static void MakeSlotCallWorker(PythonContext/*!*/ state, PythonTypeSlot/*!*/ slotTarget, Expression/*!*/ self, ConditionalBuilder/*!*/ bodyBuilder, params Expression/*!*/[]/*!*/ args) {
            // Generate:
            // 
            // SlotTryGetValue(context, slot, selfType, out callable) && (tmp=callable(args)) != NotImplemented) ?
            //      tmp :
            //      RestOfOperation
            //
            ParameterExpression callable = Ast.Variable(typeof(object), "slot");
            ParameterExpression tmp = Ast.Variable(typeof(object), "slot");

            bodyBuilder.AddCondition(
                Ast.AndAlso(
                    Ast.Call(
                        typeof(PythonOps).GetMethod("SlotTryGetValue"),
                        AstUtils.Constant(state.SharedContext),
                        AstUtils.Convert(Utils.WeakConstant(slotTarget), typeof(PythonTypeSlot)),
                        AstUtils.Convert(self, typeof(object)),
                        Ast.Call(
                            typeof(DynamicHelpers).GetMethod("GetPythonType"),
                            AstUtils.Convert(self, typeof(object))
                        ),
                        callable
                    ),
                    Ast.NotEqual(
                        Ast.Assign(
                            tmp,
                            DynamicExpression.Dynamic(
                                state.Invoke(
                                    new CallSignature(args.Length)
                                ),
                                typeof(object),
                                ArrayUtils.Insert(AstUtils.Constant(state.SharedContext), (Expression)callable, args)
                            )
                        ),
                        Ast.Property(null, typeof(PythonOps).GetProperty("NotImplemented"))
                    )
                ),
                tmp
            );
            bodyBuilder.AddVariable(callable);
            bodyBuilder.AddVariable(tmp);
        }
开发者ID:jdhardy,项目名称:ironpython,代码行数:42,代码来源:PythonProtocol.Operations.cs

示例2: InvokeKeywords

 /// <summary>
 /// Creates a new InvokeBinder which will call with positional and keyword splatting.
 /// 
 /// The signature of the target site should be object(function), object[], dictionary, retType
 /// </summary>
 public static PythonInvokeBinder/*!*/ InvokeKeywords(PythonContext/*!*/ state) {
     return state.Invoke(
         new CallSignature(new Argument(ArgumentType.List), new Argument(ArgumentType.Dictionary))
     );
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:10,代码来源:Binders.cs

示例3: GetSlotOrFunction

        public static SlotOrFunction/*!*/ GetSlotOrFunction(PythonContext/*!*/ state, string op, params DynamicMetaObject[] types) {
            PythonTypeSlot slot;
            SlotOrFunction res;
            if (TryGetBinder(state, types, op, null, out res)) {
                if (res != SlotOrFunction.Empty) {
                    return res;
                }
            } else if (MetaUserObject.GetPythonType(types[0]).TryResolveSlot(state.SharedContext, op, out slot)) {
                ParameterExpression tmp = Ast.Variable(typeof(object), "slotVal");

                Expression[] args = new Expression[types.Length - 1];
                for (int i = 1; i < types.Length; i++) {
                    args[i - 1] = types[i].Expression;
                }
                return new SlotOrFunction(
                    new DynamicMetaObject(
                        Ast.Block(
                            new ParameterExpression[] { tmp },
                            MetaPythonObject.MakeTryGetTypeMember(
                                state,
                                slot,
                                tmp,
                                types[0].Expression,
                                Ast.Call(
                                    typeof(DynamicHelpers).GetMethod("GetPythonType"),
                                    types[0].Expression
                                )
                            ),
                            Ast.Dynamic(
                                state.Invoke(
                                    new CallSignature(args.Length)
                                ),
                                typeof(object),
                                ArrayUtils.Insert<Expression>(
                                    AstUtils.Constant(state.SharedContext),
                                    tmp,
                                    args
                                )
                            )
                        ),
                        BindingRestrictions.Combine(types).Merge(BindingRestrictionsHelpers.GetRuntimeTypeRestriction(types[0].Expression, types[0].GetLimitType()))
                    ),
                    slot
                );
            }

            return SlotOrFunction.Empty;
        }
开发者ID:jschementi,项目名称:iron,代码行数:48,代码来源:SlotOrFunction.cs

示例4: InvokeSplat

 /// <summary>
 /// Creates a new InvokeBinder which will call with positional splatting.
 /// 
 /// The signature of the target site should be object(function), object[], retType
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 public static PythonInvokeBinder/*!*/ InvokeSplat(PythonContext/*!*/ state) {
     return state.Invoke(
         new CallSignature(new Argument(ArgumentType.List))
     );
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:12,代码来源:Binders.cs

示例5: Invoke

 public static Expression/*!*/ Invoke(Expression codeContext, PythonContext/*!*/ binder, Type/*!*/ resultType, CallSignature signature, params Expression/*!*/[]/*!*/ args) {
     return Ast.Dynamic(
         binder.Invoke(
             signature
         ),
         resultType,
         ArrayUtils.Insert(codeContext, args)
     );
 }
开发者ID:jschementi,项目名称:iron,代码行数:9,代码来源:BindingHelpers.cs


注:本文中的PythonContext.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。