Beispiel #1
0
        public override bool IsSubclassOf(object other)
        {
            ReflectedType rt = other as ReflectedType;

            if (rt != null)
            {
                if (type == rt.type || type.IsSubclassOf(rt.type))
                {
                    return(true);
                }

                Type otherTypeToExtend = rt.GetTypeToExtend();
                if (otherTypeToExtend != null)
                {
                    if (type == otherTypeToExtend || type.IsSubclassOf(otherTypeToExtend))  //!!! inefficient in most cases
                    {
                        return(true);
                    }

                    foreach (Type interfaceType in type.GetInterfaces())
                    {
                        if (interfaceType == otherTypeToExtend)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            if (this.Equals(other))
            {
                return(true);
            }

            foreach (DynamicType baseType in BaseClasses)
            {
                if (baseType.IsSubclassOf(other))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// If we have only interfaces, we'll need to insert object's base
        /// </summary>
        private static Tuple EnsureBaseType(Tuple bases)
        {
            foreach (object baseClass in bases)
            {
                if (baseClass is OldClass)
                {
                    continue;
                }

                ReflectedType reflectedBaseType = baseClass as ReflectedType;
                if (reflectedBaseType == null || !reflectedBaseType.GetTypeToExtend().IsInterface)
                {
                    // Found a concrete (non-interface) type. We are done.
                    return(bases);
                }
            }

            // We found only interfaces. We need do add System.Object to the bases
            return(new Tuple(bases, TypeCache.Object));
        }