GetGenericTypeVarRef() public static method

public static GetGenericTypeVarRef ( Type type, List scope ) : GenericTypeVar
type System.Type
scope List
return GenericTypeVar
Esempio n. 1
0
        private void DeriveGenericTypeVariables()
        {
            //FieldInfo field = fieldDescriptor.Field;
            Type genericType = Field.FieldType;
            List <GenericTypeVar> derivedGenericTypeVars = new List <GenericTypeVar>();

            if (genericType.IsGenericParameter)
            {
                GenericTypeVar g = GenericTypeVar.GetGenericTypeVarRef(genericType, GetGenericTypeVarsContext());
                derivedGenericTypeVars.Add(g);
            }
            else
            {
                TypeInfo typeInfo = genericType.GetTypeInfo();
                if (typeInfo.IsGenericType)
                {
                    Type[] types = typeInfo.GenericTypeArguments;

                    if (types == null | types.Length <= 0)
                    {
                        return;
                    }

                    foreach (Type t in types)
                    {
                        GenericTypeVar g = GenericTypeVar.GetGenericTypeVarRef(t, GetGenericTypeVarsContext());
                        derivedGenericTypeVars.Add(g);
                    }
                }
            }

            SetGenericTypeVars(derivedGenericTypeVars);
        }
Esempio n. 2
0
        public static void CheckTypeParameterizedTypeImpl(GenericTypeVar g, Type type)
        {
            TypeInfo typeInfo = type.GetTypeInfo();

            if (typeInfo.IsGenericType)
            {
                g.ClassDescriptor = ClassDescriptor.GetClassDescriptor(type);

                Type[] types = typeInfo.GenericTypeArguments;

                foreach (Type t in types)
                {
                    g.AddGenericTypeVarArg(GenericTypeVar.GetGenericTypeVarRef(t, g.Scope));
                }
            }
        }
Esempio n. 3
0
        public static void CheckBoundParameterizedTypeImpl(GenericTypeVar g, Type bound)
        {
            TypeInfo typeInfo = bound.GetTypeInfo();

            if (typeInfo.IsGenericType)
            {
                g.ConstraintClassDescriptor = ClassDescriptor.GetClassDescriptor(bound);

                Type[] types = typeInfo.GenericTypeArguments;

                foreach (Type type in types)
                {
                    g.AddContraintGenericTypeVarArg(GenericTypeVar.GetGenericTypeVarRef(type, g.Scope));
                }
            }
        }
Esempio n. 4
0
        public static List <GenericTypeVar> GetGenericTypeVars(Type parameterizedType, List <GenericTypeVar> scope)
        {
            Type[] types = parameterizedType.GenericTypeArguments;

            if (types.Length <= 0)
            {
                return(null);
            }

            List <GenericTypeVar> returnValue = new List <GenericTypeVar>();

            foreach (Type t in types)
            {
                GenericTypeVar g = GenericTypeVar.GetGenericTypeVarRef(t, scope);
                returnValue.Add(g);
            }

            return(returnValue);
        }