コード例 #1
0
ファイル: OldClass.cs プロジェクト: weimingtom/IronPythonMod
        public override bool IsSubclassOf(object other)
        {
            if (this == other)
            {
                return(true);
            }

            DynamicType dt = other as DynamicType;

            if (dt == null)
            {
                return(false);
            }

            Tuple bases = BaseClasses;

            foreach (object b in bases)
            {
                OldClass bc = b as OldClass;
                if (bc != null && bc.IsSubclassOf(other))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        // Is this an exception object (as defined by Python)?
        static bool IsExceptionObject(object e)
        {
            if (e == null)
            {
                return(false);
            }
            if (e is Exception)
            {
                return(true);
            }

            // It could be a PythonType created by CreateExceptionMapping
            if (e is OldInstance)
            {
                OldClass oldClass = ((OldInstance)e).__class__;
                return(oldClass.IsSubclassOf(clrToPython[typeof(Exception)]));
            }

            return(false);
        }