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); }
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)); } } }
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)); } } }
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); }