Ejemplo n.º 1
0
        private TypeReference TypeReferenceFor(TypeNameParseInfo typeNameInfo)
        {
            TypeReference typeByName = this.GetTypeByName(CecilElementTypeNameFor(typeNameInfo), typeNameInfo.Assembly);

            if (typeByName == null)
            {
                throw new TypeResolutionException(typeNameInfo);
            }
            if (typeNameInfo.HasGenericArguments)
            {
                GenericInstanceType genericInstanceType = new GenericInstanceType(typeByName);
                foreach (TypeNameParseInfo info in typeNameInfo.TypeArguments)
                {
                    genericInstanceType.GenericArguments.Add(this.TypeReferenceFor(info));
                }
                genericInstanceType.Accept(this._visitor);
                typeByName = genericInstanceType;
            }
            if (typeNameInfo.IsPointer)
            {
                throw new TypeResolutionException(typeNameInfo);
            }
            if (!typeNameInfo.IsArray)
            {
                return(typeByName);
            }
            ArrayType type2 = new ArrayType(typeByName, typeNameInfo.Ranks[0]);

            for (int i = 1; i < typeNameInfo.Ranks.Length; i++)
            {
                type2 = new ArrayType(type2, typeNameInfo.Ranks[i]);
            }
            type2.Accept(this._visitor);
            return(type2);
        }