Boo.Lang.Compiler.TypeSystem.Generics.GenericsServices.GetTypeGenerity C# (CSharp) Метод

GetTypeGenerity() публичный статический Метод

Determines the number of open generic parameters in the specified type.
public static GetTypeGenerity ( IType type ) : int
type IType
Результат int
        public static int GetTypeGenerity(IType type)
        {
            if (type.IsByRef || type.IsArray)
                return GetTypeGenerity(type.ElementType);

            if (type is IGenericParameter)
                return 1;

            // Generic parameters and generic arguments both contribute
            // to a types genrity. Note that a nested type can be both a generic definition
            // and a constructed type: Outer[of int].Inner[of T]
            int generity = 0;

            if (type.GenericInfo != null)
                generity += type.GenericInfo.GenericParameters.Length;

            if (type.ConstructedInfo != null)
                foreach (IType typeArg in type.ConstructedInfo.GenericArguments)
                    generity += GetTypeGenerity(typeArg);

            return generity;
        }

Usage Example

Пример #1
0
 protected bool IsFullyConstructed()
 {
     return(GenericsServices.GetTypeGenerity(this) == 0);
 }