/// <summary> /// Determines if this class represents the same class, or a subclass, of the specified class. /// </summary> public bool IsOfType(ITypeSpec spec) { if (spec.Equals(this)) { return(true); } if (Interfaces.Any(interfaceSpec => interfaceSpec.IsOfType(spec))) { return(true); } // match covariant generic types if (Type.IsGenericType && IsCollection) { Type otherType = ((TypeSpec)spec).Type; if (otherType.IsGenericType && Type.GetGenericArguments().Count() == 1 && otherType.GetGenericArguments().Count() == 1) { if (Type.GetGenericTypeDefinition() == (typeof(IQueryable <>)) && Type.GetGenericTypeDefinition() == otherType.GetGenericTypeDefinition()) { Type genericArgument = Type.GetGenericArguments().Single(); Type otherGenericArgument = otherType.GetGenericArguments().Single(); Type otherGenericParameter = otherType.GetGenericTypeDefinition().GetGenericArguments().Single(); if ((otherGenericParameter.GenericParameterAttributes & GenericParameterAttributes.Covariant) != 0) { if (otherGenericArgument.IsAssignableFrom(genericArgument)) { return(true); } } } } } return(Superclass != null && Superclass.IsOfType(spec)); }
private bool FindServiceOnSpecOrSpecSuperclass(ITypeSpec spec) { return(spec != null && (spec.Equals(OnSpec) || FindServiceOnSpecOrSpecSuperclass(spec.Superclass))); }
private bool FindServiceOnSpecOrSpecSuperclass(ITypeSpec spec) { return spec != null && (spec.Equals(OnSpec) || FindServiceOnSpecOrSpecSuperclass(spec.Superclass)); }