public static bool IsAssignableFrom(ITypeInfo self, ITypeInfo other)
        {
            if (self == null || other == null)
            {
                return(false);
            }

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

            if (self.IsInterface)
            {
                return(other.GetInterfaces().Any(self.Equals));
            }

            var baseType = other.BaseType;

            while (baseType != null)
            {
                if (self.Equals(baseType))
                {
                    return(true);
                }
                baseType = baseType.BaseType;
            }

            return(false);
        }
Exemplo n.º 2
0
 public static bool Accept(ITypeInfo typeInfo)
 {
     return(typeInfo.IsGenericType &&
            typeInfo.GetGenericArguments().Length == 1 &&
            typeInfo.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition().Equals(TypeInfo.From(typeof(ICollection <>)))));
 }