Esempio n. 1
0
        private static bool Match(Type baseType, Type type)
        {
            var r = TypeTools.IsAssignableFrom(baseType, type);

            if (r)
            {
                return(true);
            }

            if (!baseType.IsGenericType())
            {
                return(false);
            }

            if (baseType.IsInterface())
            {
                return(TypeTools.GetInterfaces(type).Select(GetUnderlinedGenericType).Any(t => baseType == t));
            }

            if (type.IsInterface())
            {
                return(false);
            }

            do
            {
                type = GetUnderlinedGenericType(type);
                if (baseType == type)
                {
                    return(true);
                }
                type = type.GetBaseType();
            } while (type != null);
            return(false);
        }