예제 #1
0
        private Type ReadType(DataKind kind)
        {
            switch (kind)
            {
            case DataKind.TypeRef_B:
                return((Type)dataMap.GetValue(reader.ReadByte()));

            case DataKind.TypeRef_S:
                return((Type)dataMap.GetValue(reader.ReadUInt16()));

            case DataKind.TypeRef:
                return((Type)dataMap.GetValue(reader.ReadInt32()));

            case DataKind.Type:
                int id           = dataMap.GetNextId();
                var assemblyName = this.ReadString();
                var typeName     = this.ReadString();

                if (this.binder == null)
                {
                    throw NoBinderException(typeName);
                }

                var type = this.binder.GetType(assemblyName, typeName);
                dataMap.AddValue(id, type);
                return(type);

            default:
                throw ExceptionUtilities.UnexpectedValue(kind);
            }
        }
예제 #2
0
파일: ObjectReader.cs 프로젝트: hokb/roslyn
        private unsafe string ReadStringLiteral(DataKind kind)
        {
            int    id = _dataMap.GetNextId();
            string value;

            if (kind == DataKind.StringUtf8)
            {
                value = _reader.ReadString();
            }
            else
            {
                // This is rare, just allocate UTF16 bytes for simplicity.

                int    characterCount = (int)ReadCompressedUInt();
                byte[] bytes          = _reader.ReadBytes(characterCount * sizeof(char));
                fixed(byte *bytesPtr = bytes)
                {
                    value = new string((char *)bytesPtr, 0, characterCount);
                }
            }

            _dataMap.AddValue(id, value);
            return(value);
        }