Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
 private bool FindServiceOnSpecOrSpecSuperclass(ITypeSpec spec)
 {
     return(spec != null && (spec.Equals(OnSpec) || FindServiceOnSpecOrSpecSuperclass(spec.Superclass)));
 }
Ejemplo n.º 3
0
 private bool FindServiceOnSpecOrSpecSuperclass(ITypeSpec spec) {
     return spec != null && (spec.Equals(OnSpec) || FindServiceOnSpecOrSpecSuperclass(spec.Superclass));
 }