Beispiel #1
0
        private TType DecodeType(ref BlobReader blobReader, int typeCode)
        {
            TType elementType;
            int   index;

            switch (typeCode)
            {
            case (int)SignatureTypeCode.Boolean:
            case (int)SignatureTypeCode.Char:
            case (int)SignatureTypeCode.SByte:
            case (int)SignatureTypeCode.Byte:
            case (int)SignatureTypeCode.Int16:
            case (int)SignatureTypeCode.UInt16:
            case (int)SignatureTypeCode.Int32:
            case (int)SignatureTypeCode.UInt32:
            case (int)SignatureTypeCode.Int64:
            case (int)SignatureTypeCode.UInt64:
            case (int)SignatureTypeCode.Single:
            case (int)SignatureTypeCode.Double:
            case (int)SignatureTypeCode.IntPtr:
            case (int)SignatureTypeCode.UIntPtr:
            case (int)SignatureTypeCode.Object:
            case (int)SignatureTypeCode.String:
            case (int)SignatureTypeCode.Void:
            case (int)SignatureTypeCode.TypedReference:
                return(_provider.GetPrimitiveType((PrimitiveTypeCode)typeCode));

            case (int)SignatureTypeCode.Pointer:
                elementType = DecodeType(ref blobReader);
                return(_provider.GetPointerType(elementType));

            case (int)SignatureTypeCode.ByReference:
                elementType = DecodeType(ref blobReader);
                return(_provider.GetByReferenceType(elementType));

            case (int)SignatureTypeCode.Pinned:
                elementType = DecodeType(ref blobReader);
                return(_provider.GetPinnedType(elementType));

            case (int)SignatureTypeCode.SZArray:
                elementType = DecodeType(ref blobReader);
                return(_provider.GetSZArrayType(elementType));

            case (int)SignatureTypeCode.FunctionPointer:
                MethodSignature <TType> methodSignature = DecodeMethodSignature(ref blobReader);
                return(_provider.GetFunctionPointerType(methodSignature));

            case (int)SignatureTypeCode.Array:
                return(DecodeArrayType(ref blobReader));

            case (int)SignatureTypeCode.RequiredModifier:
                return(DecodeModifiedType(ref blobReader, isRequired: true));

            case (int)SignatureTypeCode.OptionalModifier:
                return(DecodeModifiedType(ref blobReader, isRequired: false));

            case (int)SignatureTypeCode.GenericTypeInstance:
                return(DecodeGenericTypeInstance(ref blobReader));

            case (int)SignatureTypeCode.GenericTypeParameter:
                index = blobReader.ReadCompressedInteger();
                return(_provider.GetGenericTypeParameter(index));

            case (int)SignatureTypeCode.GenericMethodParameter:
                index = blobReader.ReadCompressedInteger();
                return(_provider.GetGenericMethodParameter(index));

            case (int)SignatureTypeHandleCode.Class:
            case (int)SignatureTypeHandleCode.ValueType:
                return(DecodeTypeDefOrRef(ref blobReader, (SignatureTypeHandleCode)typeCode));

            default:
                throw new BadImageFormatException(SR.Format(SR.UnexpectedSignatureTypeCode, typeCode));
            }
        }