private void UpdateSingleDependingType(GenericInstanceType dependingType, TypeReference theArgument, int argumentIndex) { int index = 0; for (index = 0; index < dependingType.GenericArguments.Count; index++) { GenericParameter t = dependingType.GenericArguments[index] as GenericParameter; if (t == null) { if (dependingType.GenericArguments[index] is GenericInstanceType) { UpdateSingleDependingType(dependingType.GenericArguments[index] as GenericInstanceType, theArgument, argumentIndex); } continue; } if (t.Owner == this.ElementMethod && t.Position == argumentIndex) { dependingType.ReplaceGenericArgumentAt(index, theArgument); } //if (t.FullName == string.Format("!!{0}", i)) //{ // break; //} } //if (index < paramType.GenericArguments.Count) //{ // paramType.ReplaceGenericArgumentAt(index, theArgument); //} }
/*Telerik Authorship*/ private TypeReference GetFixedReturnType(TypeReference type) { if (type == null) { return(null); } if (type.IsOptionalModifier) { OptionalModifierType omt = (OptionalModifierType)type; TypeReference fixedElement = GetFixedReturnType(omt.ElementType); return(new OptionalModifierType(omt.ModifierType, fixedElement)); } if (type.IsRequiredModifier) { RequiredModifierType rmt = (RequiredModifierType)type; TypeReference fixedElement = GetFixedReturnType(rmt.ElementType); return(new RequiredModifierType(rmt.ModifierType, fixedElement)); } if (type.IsGenericParameter) { return(GetActualType(type)); } if (type.IsArray) { ArrayType at = (ArrayType)type; int rank = at.Rank; TypeReference arrayElementType = at.ElementType; arrayElementType = GetFixedReturnType(arrayElementType); return(new ArrayType(arrayElementType, rank)); } if (type.IsPointer) { TypeReference fixedElement = GetFixedReturnType(((PointerType)type).ElementType); return(new PointerType(fixedElement)); } if (type.IsByReference) { TypeReference fixedElement = GetFixedReturnType(((ByReferenceType)type).ElementType); return(new ByReferenceType(fixedElement)); } if (type.IsGenericInstance && DeclaringType.IsGenericInstance) { GenericInstanceType result = type as GenericInstanceType; GenericInstanceType declaringTypeGenericInstance = DeclaringType as GenericInstanceType; TypeReference declaringElementType = DeclaringType.GetElementType(); for (int i = 0; i < result.GenericArguments.Count; i++) { GenericParameter currentParam = result.GenericArguments[i] as GenericParameter; if (currentParam != null && currentParam.Owner == declaringElementType) { if (declaringTypeGenericInstance.PostionToArgument.ContainsKey(currentParam.Position)) { result.ReplaceGenericArgumentAt(i, declaringTypeGenericInstance.PostionToArgument[currentParam.position]); } } } return(result); } return(type); }