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


C# Binding.PythonBinder类代码示例

本文整理汇总了C#中IronPython.Runtime.Binding.PythonBinder的典型用法代码示例。如果您正苦于以下问题:C# PythonBinder类的具体用法?C# PythonBinder怎么用?C# PythonBinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PythonBinder类属于IronPython.Runtime.Binding命名空间,在下文中一共展示了PythonBinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeGetExpression

        /// <summary>
        /// Gets an expression which is used for accessing this slot.  If the slot lookup fails the error expression
        /// is used again.
        /// 
        /// The default implementation just calls the TryGetValue method.  Subtypes of PythonTypeSlot can override
        /// this and provide a more optimal implementation.
        /// </summary>
        internal virtual Expression/*!*/ MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, Expression instance, Expression/*!*/ owner, Expression/*!*/ error) {
            ParameterExpression tmp = Ast.Variable(typeof(object), "slotTmp");
            Expression call = Ast.Call(
                 typeof(PythonOps).GetMethod("SlotTryGetValue"),
                 codeContext,
                 AstUtils.Convert(AstUtils.WeakConstant(this), typeof(PythonTypeSlot)),
                 instance ?? AstUtils.Constant(null),
                 owner,
                 tmp
            );

            if (!GetAlwaysSucceeds) {
                call = Ast.Condition(
                    call,
                    tmp,
                    AstUtils.Convert(error, typeof(object))
                );
            } else {
                call = Ast.Block(call, tmp);
            }

            return Ast.Block(
                new ParameterExpression[] { tmp },
                call
            );
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:33,代码来源:PythonTypeSlot.cs

示例2: PythonOverloadResolver

 // instance method call:
 public PythonOverloadResolver(PythonBinder binder, DynamicMetaObject instance, IList<DynamicMetaObject> args, CallSignature signature,
     Expression codeContext)
     : base(binder, instance, args, signature)
 {
     Assert.NotNull(codeContext);
     _context = codeContext;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:PythonOverloadResolver.cs

示例3: ShouldWarn

        public static bool ShouldWarn(PythonBinder/*!*/ binder, MethodBase/*!*/ method, out WarningInfo info) {
            Assert.NotNull(method);

            ObsoleteAttribute[] os = (ObsoleteAttribute[])method.GetCustomAttributes(typeof(ObsoleteAttribute), true);
            if (os.Length > 0) {
                info = new WarningInfo(
                    PythonExceptions.DeprecationWarning,
                    String.Format("{0}.{1} has been obsoleted.  {2}",
                        NameConverter.GetTypeName(method.DeclaringType),
                        method.Name,
                        os[0].Message
                    )
                );

                return true;
            }

            if (binder.WarnOnPython3000) {
                Python3WarningAttribute[] py3kwarnings = (Python3WarningAttribute[])method.GetCustomAttributes(typeof(Python3WarningAttribute), true);
                if (py3kwarnings.Length > 0) {
                    info = new WarningInfo(
                        PythonExceptions.DeprecationWarning,
                        py3kwarnings[0].Message
                    );

                    return true;
                }
            }

#if !SILVERLIGHT
            // no apartment states on Silverlight
            if (method.DeclaringType == typeof(Thread)) {
                if (method.Name == "Sleep") {
                    info = new WarningInfo(
                        PythonExceptions.RuntimeWarning,
                        "Calling Thread.Sleep on an STA thread doesn't pump messages.  Use Thread.CurrentThread.Join instead.",
                        Expression.Equal(
                            Expression.Call(
                                Expression.Property(
                                    null,
                                    typeof(Thread).GetProperty("CurrentThread")
                                ),
                                typeof(Thread).GetMethod("GetApartmentState")
                            ),
                            AstUtils.Constant(ApartmentState.STA)
                        ),
                        () => Thread.CurrentThread.GetApartmentState() == ApartmentState.STA
                    );

                    return true;
                }
            }
#endif

            info = null;
            return false;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:57,代码来源:BindingWarnings.cs

示例4: MakeGetExpression

        internal override Expression/*!*/ MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, Expression instance, Expression/*!*/ owner, Expression/*!*/ error) {
            if (instance != null) {
                return Ast.Call(
                    typeof(PythonOps).GetMethod("MakeBoundBuiltinFunction"),
                    Ast.Constant(_template),
                    instance
                );
            }

            return Ast.Constant(this);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:11,代码来源:BuiltinMethodDescriptor.cs

示例5: MakeGetExpression

 internal override void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, Expression instance, Expression/*!*/ owner, ConditionalBuilder/*!*/ builder) {
     if (instance != null) {
         builder.FinishCondition(
             Ast.Call(
                 typeof(PythonOps).GetMethod("MakeBoundBuiltinFunction"),
                 AstUtils.Constant(_template),
                 instance
             )
         );
     } else {
         builder.FinishCondition(AstUtils.Constant(this));
     }
 }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:13,代码来源:BuiltinMethodDescriptor.cs

示例6: MakeGetExpression

        /// <summary>
        /// Gets an expression which is used for accessing this slot.  If the slot lookup fails the error expression
        /// is used again.
        /// 
        /// The default implementation just calls the TryGetValue method.  Subtypes of PythonTypeSlot can override
        /// this and provide a more optimal implementation.
        /// </summary>
        internal virtual void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, DynamicMetaObject instance, DynamicMetaObject/*!*/ owner, ConditionalBuilder/*!*/ builder) {
            ParameterExpression tmp = Ast.Variable(typeof(object), "slotTmp");
            Expression call = Ast.Call(
                 typeof(PythonOps).GetMethod("SlotTryGetValue"),
                 codeContext,
                 AstUtils.Convert(AstUtils.WeakConstant(this), typeof(PythonTypeSlot)),
                 instance != null ? instance.Expression : AstUtils.Constant(null),
                 owner.Expression,
                 tmp
            );

            builder.AddVariable(tmp);
            if (!GetAlwaysSucceeds) {
                builder.AddCondition(
                    call,
                    tmp
                );
            } else {
                builder.FinishCondition(Ast.Block(call, tmp));
            }
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:28,代码来源:PythonTypeSlot.cs

示例7: GetMember

        /// <summary>
        /// Gets the statically known member from the type with the specific name.  Searches only the specified type to find the member.
        /// </summary>
        public static MemberGroup/*!*/ GetMember(PythonBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) {
            Assert.NotNull(binder, action, type, name);

            PerfTrack.NoteEvent(PerfTrack.Categories.ReflectedTypes, String.Format("LookupMember: {0} {1}", type.Name, name));
            return GetMemberGroup(new LookupBinder(binder), action, type, name);
        }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:9,代码来源:TypeInfo.cs

示例8: ResolveBinder

 public ResolveBinder(PythonBinder/*!*/ binder)
     : base(binder) {
 }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:3,代码来源:TypeInfo.cs

示例9: MakeGetExpression

 internal override void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, DynamicMetaObject instance, DynamicMetaObject/*!*/ owner, ConditionalBuilder/*!*/ builder) {
     if (Getter.Length != 0 && !Getter[0].IsPublic) {
         // fallback to runtime call
         base.MakeGetExpression(binder, codeContext, instance, owner, builder);
     } else if (NeedToReturnProperty(instance, Getter)) {
         builder.FinishCondition(AstUtils.Constant(this));
     } else if (Getter[0].ContainsGenericParameters) {
         builder.FinishCondition(
             DefaultBinder.MakeError(
                 binder.MakeContainsGenericParametersError(
                     MemberTracker.FromMemberInfo(_info)
                 ),
                 typeof(object)
             ).Expression
         );
     } else if (instance != null) {
         builder.FinishCondition(
             AstUtils.Convert(
                 binder.MakeCallExpression(
                     new PythonOverloadResolverFactory(binder, codeContext),
                     Getter[0],
                     instance
                 ).Expression,
                 typeof(object)
             )
         );
     } else {
         builder.FinishCondition(
             AstUtils.Convert(
                 binder.MakeCallExpression(
                     new PythonOverloadResolverFactory(binder, codeContext),
                     Getter[0]
                 ).Expression,
                 typeof(object)
             )
         );                
     }
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:38,代码来源:ReflectedProperty.cs

示例10: GetMembersAll

        /// <summary>
        /// Gets all the statically known members from the specified type.  Searches the entire type hierarchy to get all possible members.
        /// 
        /// The result may include multiple resolution.  It is the callers responsibility to only treat the 1st one by name as existing.
        /// </summary>
        public static IList<ResolvedMember/*!*/>/*!*/ GetMembersAll(PythonBinder/*!*/ binder, MemberRequestKind/*!*/ action, Type/*!*/ type) {
            Assert.NotNull(binder, action, type);

            return GetResolvedMembers(new ResolveBinder(binder), action, type);
        }
开发者ID:Jaykul,项目名称:IronLangs,代码行数:10,代码来源:PythonTypeInfo.cs

示例11: MakeInitCall

            public override DynamicMetaObject/*!*/ MakeInitCall(PythonBinder/*!*/ binder, DynamicMetaObject/*!*/ createExpr) {
                Expression init = Ast.Call(
                    typeof(PythonOps).GetMethod("GetMixedMember"),
                    CodeContext,
                    Ast.Convert(Arguments.Self.Expression, typeof(PythonType)),
                    AstUtils.Convert(createExpr.Expression, typeof(object)),
                    AstUtils.Constant("__init__")
                );

                return MakeDefaultInit(binder, createExpr, init);
            }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:11,代码来源:MetaPythonType.Calls.cs

示例12: PythonOverloadResolverFactory

 public PythonOverloadResolverFactory(PythonBinder/*!*/ binder, Expression/*!*/ codeContext)
 {
     Assert.NotNull(binder, codeContext);
     _binder = binder;
     _codeContext = codeContext;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:6,代码来源:PythonOverloadResolver.cs

示例13: MakeGetExpression

 internal override void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, DynamicMetaObject instance, DynamicMetaObject/*!*/ owner, ConditionalBuilder/*!*/ builder) {
     if (!_info.IsPublic || _info.DeclaringType.ContainsGenericParameters) {
         // fallback to reflection
         base.MakeGetExpression(binder, codeContext, instance, owner, builder);
     } else if (instance == null) {
         if (_info.IsStatic) {
             builder.FinishCondition(AstUtils.Convert(Ast.Field(null, _info), typeof(object)));
         } else {
             builder.FinishCondition(Ast.Constant(this));
         }
     } else {
         builder.FinishCondition(
             AstUtils.Convert(
                 Ast.Field(
                     binder.ConvertExpression(
                         instance.Expression,
                         _info.DeclaringType,
                         ConversionResultKind.ExplicitCast,
                         new PythonOverloadResolverFactory(binder, codeContext)
                     ),
                     _info
                 ),
                 typeof(object)
             )
         );
     }
 }
开发者ID:techarch,项目名称:ironruby,代码行数:27,代码来源:ReflectedField.cs

示例14: PythonExtensionBinder

 public PythonExtensionBinder(PythonBinder binder, ExtensionMethodSet extensionMethods)
     : base(binder) {
     _extMethodSet = extensionMethods;
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:4,代码来源:PythonExtensionBinder.cs

示例15: MakeDefaultInit

            protected DynamicMetaObject/*!*/ MakeDefaultInit(PythonBinder/*!*/ binder, DynamicMetaObject/*!*/ createExpr, Expression/*!*/ init) {
                List<Expression> args = new List<Expression>();
                args.Add(CodeContext);
                args.Add(Expression.Convert(createExpr.Expression, typeof(object)));
                foreach (DynamicMetaObject mo in Arguments.Arguments) {
                    args.Add(mo.Expression);
                }

                return new DynamicMetaObject(
                    DynamicExpression.Dynamic(
                        ((PythonType)Arguments.Self.Value).GetLateBoundInitBinder(Arguments.Signature),
                        typeof(object),
                        args.ToArray()
                    ),
                    Arguments.Self.Restrictions.Merge(createExpr.Restrictions)
                );                
            }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:17,代码来源:MetaPythonType.Calls.cs


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