GetTypeGenerity() public static method

Determines the number of open generic parameters in the specified type.
public static GetTypeGenerity ( IType type ) : int
type IType
return int
Ejemplo n.º 1
0
        private int MoreSpecific(IType t1, IType t2)
        {
            // Dive into array types and ref types
            if (t1.IsArray && t2.IsArray || t1.IsByRef && t2.IsByRef)
            {
                return(MoreSpecific(t1.ElementType, t2.ElementType));
            }

            // A more concrete type is more specfic
            int result = GenericsServices.GetTypeConcreteness(t1) - GenericsServices.GetTypeConcreteness(t2);

            if (result != 0)
            {
                return(result);
            }

            // With equal concreteness, the more generic type is more specific.
            //First search for open args, then for all args
            result = GenericsServices.GetTypeGenerity(t1) - GenericsServices.GetTypeGenerity(t2);
            if (result != 0)
            {
                return(result);
            }
            result = GenericsServices.GetTypeGenericDepth(t1) - GenericsServices.GetTypeGenericDepth(t2);
            if (result != 0)
            {
                return(result);
            }

            // If both types have the same genrity, the deeper-nested type is more specific
            return(GetLogicalTypeDepth(t1) - GetLogicalTypeDepth(t2));
        }
Ejemplo n.º 2
0
        private int MoreSpecific(IType t1, IType t2)
        {
            // Dive into array types and ref types
            if (t1.IsArray && t2.IsArray || t1.IsByRef && t2.IsByRef)
            {
                return(MoreSpecific(t1.ElementType, t2.ElementType));
            }

            // The less-generic type is more specific
            int result = GenericsServices.GetTypeGenerity(t2) - GenericsServices.GetTypeGenerity(t1);

            if (result != 0)
            {
                return(result);
            }

            // If both types have the same genrity, the deeper-nested type is more specific
            return(GetLogicalTypeDepth(t1) - GetLogicalTypeDepth(t2));
        }