internal IMetadataConstant GetDefaultValue( MetadataObject metadataObject ) { uint constRowId = this.PEFileReader.ConstantTable.GetConstantRowId(metadataObject.TokenValue); if (constRowId == 0) return Dummy.Constant; ConstantRow constRow = this.PEFileReader.ConstantTable[constRowId]; MemoryBlock constValueMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(constRow.Value); MemoryReader memoryReader = new MemoryReader(constValueMemoryBlock); switch (constRow.Type) { case ElementType.Boolean: { byte val = memoryReader.ReadByte(); return new ConstantExpression(this.PlatformType.SystemBoolean, val != 0); } case ElementType.Char: return new ConstantExpression(this.PlatformType.SystemChar, memoryReader.ReadChar()); case ElementType.Int8: return new ConstantExpression(this.PlatformType.SystemInt8, memoryReader.ReadSByte()); case ElementType.Int16: return new ConstantExpression(this.PlatformType.SystemInt16, memoryReader.ReadInt16()); case ElementType.Int32: return new ConstantExpression(this.PlatformType.SystemInt32, memoryReader.ReadInt32()); case ElementType.Int64: return new ConstantExpression(this.PlatformType.SystemInt64, memoryReader.ReadInt64()); case ElementType.UInt8: return new ConstantExpression(this.PlatformType.SystemUInt8, memoryReader.ReadByte()); case ElementType.UInt16: return new ConstantExpression(this.PlatformType.SystemUInt16, memoryReader.ReadUInt16()); case ElementType.UInt32: return new ConstantExpression(this.PlatformType.SystemUInt32, memoryReader.ReadUInt32()); case ElementType.UInt64: return new ConstantExpression(this.PlatformType.SystemUInt64, memoryReader.ReadUInt64()); case ElementType.Single: return new ConstantExpression(this.PlatformType.SystemFloat32, memoryReader.ReadSingle()); case ElementType.Double: return new ConstantExpression(this.PlatformType.SystemFloat64, memoryReader.ReadDouble()); case ElementType.String: { int byteLen = memoryReader.Length; string/*?*/ value; if (byteLen == -1) { value = null; } else if (byteLen == 0) { value = string.Empty; } else { value = memoryReader.ReadUTF16WithSize(byteLen); } return new ConstantExpression(this.PlatformType.SystemString, value); } case ElementType.Class: return new ConstantExpression(this.PlatformType.SystemObject, null); } // MDError... return Dummy.Constant; }