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


C# PythonType.IsSubclassOf方法代码示例

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


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

示例1: __new__

        public static PythonModule/*!*/ __new__(CodeContext/*!*/ context, PythonType/*!*/ cls, params object[]/*!*/ args\u00F8) {
            PythonModule res;
            if (cls == TypeCache.Module) {
                res = new PythonModule();
            } else if (cls.IsSubclassOf(TypeCache.Module)) {
                res = (PythonModule)cls.CreateInstance(context);
            } else {
                throw PythonOps.TypeError("{0} is not a subtype of module", cls.Name);
            }

            return res;
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:12,代码来源:PythonModule.cs

示例2: __new__

        public static Scope/*!*/ __new__(CodeContext/*!*/ context, PythonType/*!*/ cls, params object[]/*!*/ args\u00F8) {
            Scope res;
            if (cls == TypeCache.Module) {
                res = new Scope(PythonDictionary.MakeSymbolDictionary());
            } else if (cls.IsSubclassOf(TypeCache.Module)) {
                res = (Scope)cls.CreateInstance(context);
            } else {
                throw PythonOps.TypeError("{0} is not a subtype of module", cls.Name);
            }

            PythonContext.GetContext(context).CreateModule(null, res, null, ModuleOptions.None);
            res.Clear();
            return res;
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:14,代码来源:ScopeOps.cs

示例3: CheckGetArgs

        private PythonType CheckGetArgs(CodeContext context, object instance, PythonType owner) {
            if (owner == null) {
                if (instance == null) throw PythonOps.TypeError("__get__(None, None) is invalid");
                owner = DynamicHelpers.GetPythonType(instance);
            } else {
                if (!owner.IsSubclassOf(DynamicHelpers.GetPythonTypeFromType(_func.DeclaringType))) {
                    throw PythonOps.TypeError("descriptor {0} for type {1} doesn't apply to type {2}",
                        PythonOps.Repr(context, _func.Name),
                        PythonOps.Repr(context, DynamicHelpers.GetPythonTypeFromType(_func.DeclaringType).Name),
                        PythonOps.Repr(context, owner.Name));
                }
            }
            if (instance != null)
                BuiltinMethodDescriptor.CheckSelfWorker(context, instance, _func);

            return owner;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:17,代码来源:ClassMethodDescriptor.cs

示例4: warn_explicit

        public static void warn_explicit(CodeContext context, object message, PythonType category, string filename, int lineno, [DefaultParameterValue(null)]string module, [DefaultParameterValue(null)]PythonDictionary registry, [DefaultParameterValue(null)]object module_globals) {
            PythonContext pContext = PythonContext.GetContext(context);
            PythonDictionary fields = (PythonDictionary)pContext.GetModuleState(_keyFields);
            PythonExceptions.BaseException msg;
            string text; // message text

            if (string.IsNullOrEmpty(module)) {
                module = (filename == null || filename == "") ? "<unknown>" : filename;
                if (module.EndsWith(".py")) {
                    module = module.Substring(0, module.Length - 3);
                }
            }
            if (registry == null) {
                registry = new PythonDictionary();
            }
            if (PythonOps.IsInstance(message, PythonExceptions.Warning)) {
                msg = (PythonExceptions.BaseException)message;
                text = msg.ToString();
                category = DynamicHelpers.GetPythonType(msg);
            } else {
                text = message.ToString();
                msg = PythonExceptions.CreatePythonThrowable(category, message.ToString());
            }

            PythonTuple key = PythonTuple.MakeTuple(text, category, lineno);
            if (registry.ContainsKey(key)) {
                return;
            }

            string action = Converter.ConvertToString(fields[_keyDefaultAction]);
            PythonTuple last_filter = null;
            bool loop_break = false;
            foreach (PythonTuple filter in (List)fields[_keyFilters]) {
                last_filter = filter;
                action = (string)filter._data[0];
                PythonRegex.RE_Pattern fMsg = (PythonRegex.RE_Pattern)filter._data[1];
                PythonType fCat = (PythonType)filter._data[2];
                PythonRegex.RE_Pattern fMod = (PythonRegex.RE_Pattern)filter._data[3];
                int fLno;
                if (filter._data[4] is int) {
                    fLno = (int)filter._data[4];
                } else {
                    fLno = (Extensible<int>)filter._data[4];
                }

                if ((fMsg == null || fMsg.match(text) != null) &&
                    category.IsSubclassOf(fCat) &&
                    (fMod == null || fMod.match(module) != null) &&
                    (fLno == 0 || fLno == lineno)) {
                    loop_break = true;
                    break;
                }
            }
            if (!loop_break) {
                action = Converter.ConvertToString(fields[_keyDefaultAction]);
            }

            switch (action) {
                case "ignore":
                    registry.Add(key, 1);
                    return;
                case "error":
                    throw msg.GetClrException();
                case "once":
                    registry.Add(key, 1);
                    PythonTuple onceKey = PythonTuple.MakeTuple(text, category);
                    PythonDictionary once_reg = (PythonDictionary)fields[_keyOnceRegistry];
                    if (once_reg.ContainsKey(onceKey)) {
                        return;
                    }
                    once_reg.Add(key, 1);
                    break;
                case "always":
                    break;
                case "module":
                    registry.Add(key, 1);
                    PythonTuple altKey = PythonTuple.MakeTuple(text, category, 0);
                    if (registry.ContainsKey(altKey)) {
                        return;
                    }
                    registry.Add(altKey, 1);
                    break;
                case "default":
                    registry.Add(key, 1);
                    break;
                default:
                    throw PythonOps.RuntimeError("Unrecognized action ({0}) in warnings.filters:\n {1}", action, last_filter);
            }

            object warnings = pContext.GetWarningsModule();
            if (warnings != null) {
                PythonCalls.Call(
                    context,
                    PythonOps.GetBoundAttr(context, warnings, "showwarning"),
                    msg, category, filename, lineno, null, null);
            } else {
                showwarning(context, msg, category, filename, lineno, null, null);
            }
        }
开发者ID:jschementi,项目名称:iron,代码行数:99,代码来源:_warnings.cs

示例5: ShouldInvokeInit

 private static bool ShouldInvokeInit(PythonType cls, PythonType newObjectType, int argCnt) {
     // don't run __init__ if it's not a subclass of ourselves,
     // or if this is the user doing type(x), or if it's a standard
     // .NET type which doesn't have an __init__ method (this is a perf optimization)
     return (!cls.IsSystemType || cls.IsPythonType) &&
         newObjectType.IsSubclassOf(cls) &&                
         (cls != TypeCache.PythonType || argCnt > 1);
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:8,代码来源:PythonTypeOps.cs

示例6: SubclassImpl

        private bool SubclassImpl(PythonType sub) {
            if (UnderlyingSystemType.IsInterface) {
                // interfaces aren't in bases, and therefore IsSubclassOf doesn't do this check.
                if (UnderlyingSystemType.IsAssignableFrom(sub.UnderlyingSystemType)) {
                    return true;
                }
            }

            return sub.IsSubclassOf(this);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:10,代码来源:PythonType.cs


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