public void TestRoundTripPrimitives() { var stream = new MemoryStream(); var writer = new ObjectWriter(stream); writer.WriteBoolean(true); writer.WriteBoolean(false); writer.WriteByte(Byte.MaxValue); writer.WriteSByte(SByte.MaxValue); writer.WriteInt16(Int16.MaxValue); writer.WriteInt32(Int32.MaxValue); writer.WriteInt32(Byte.MaxValue); writer.WriteInt32(Int16.MaxValue); writer.WriteInt64(Int64.MaxValue); writer.WriteUInt16(UInt16.MaxValue); writer.WriteUInt32(UInt32.MaxValue); writer.WriteUInt64(UInt64.MaxValue); writer.WriteDecimal(Decimal.MaxValue); writer.WriteDouble(Double.MaxValue); writer.WriteSingle(Single.MaxValue); writer.WriteChar('X'); writer.WriteString("YYY"); writer.WriteCompressedUInt(Byte.MaxValue >> 2); // 6 bits writer.WriteCompressedUInt(UInt16.MaxValue >> 2); // 14 bits writer.WriteCompressedUInt(UInt32.MaxValue >> 2); // 30 bits var dt = DateTime.Now; writer.WriteDateTime(dt); writer.Dispose(); stream.Position = 0; var reader = new ObjectReader(stream); Assert.Equal(true, reader.ReadBoolean()); Assert.Equal(false, reader.ReadBoolean()); Assert.Equal(Byte.MaxValue, reader.ReadByte()); Assert.Equal(SByte.MaxValue, reader.ReadSByte()); Assert.Equal(Int16.MaxValue, reader.ReadInt16()); Assert.Equal(Int32.MaxValue, reader.ReadInt32()); Assert.Equal(Byte.MaxValue, reader.ReadInt32()); Assert.Equal(Int16.MaxValue, reader.ReadInt32()); Assert.Equal(Int64.MaxValue, reader.ReadInt64()); Assert.Equal(UInt16.MaxValue, reader.ReadUInt16()); Assert.Equal(UInt32.MaxValue, reader.ReadUInt32()); Assert.Equal(UInt64.MaxValue, reader.ReadUInt64()); Assert.Equal(Decimal.MaxValue, reader.ReadDecimal()); Assert.Equal(Double.MaxValue, reader.ReadDouble()); Assert.Equal(Single.MaxValue, reader.ReadSingle()); Assert.Equal('X', reader.ReadChar()); Assert.Equal("YYY", reader.ReadString()); Assert.Equal((UInt32)(Byte.MaxValue >> 2), reader.ReadCompressedUInt()); Assert.Equal((UInt32)(UInt16.MaxValue >> 2), reader.ReadCompressedUInt()); Assert.Equal(UInt32.MaxValue >> 2, reader.ReadCompressedUInt()); Assert.Equal(dt, reader.ReadDateTime()); reader.Dispose(); }
protected DiagnosticInfo(ObjectReader reader) { this.messageProvider = (CommonMessageProvider)reader.ReadValue(); this.errorCode = (int)reader.ReadCompressedUInt(); this.isWarningAsError = reader.ReadBoolean(); var count = (int)reader.ReadCompressedUInt(); if (count > 0) { this.arguments = new string[count]; for (int i = 0; i < count; i++) { this.arguments[i] = reader.ReadString(); } } }
protected DiagnosticInfo(ObjectReader reader) { _messageProvider = (CommonMessageProvider)reader.ReadValue(); _errorCode = (int)reader.ReadCompressedUInt(); _effectiveSeverity = (DiagnosticSeverity)reader.ReadInt32(); _defaultSeverity = (DiagnosticSeverity)reader.ReadInt32(); var count = (int)reader.ReadCompressedUInt(); if (count == 0) { _arguments = SpecializedCollections.EmptyObjects; } else if (count > 0) { _arguments = new string[count]; for (int i = 0; i < count; i++) { _arguments[i] = reader.ReadString(); } } }
private LocalizableResourceString(ObjectReader reader) { _resourceSource = (Type)reader.ReadValue(); _nameOfLocalizableResource = reader.ReadString(); _resourceManager = new ResourceManager(_resourceSource); var length = (int)reader.ReadCompressedUInt(); if (length == 0) { _formatArguments = SpecializedCollections.EmptyArray <string>(); } else { var argumentsBuilder = ArrayBuilder <string> .GetInstance(length); for (int i = 0; i < length; i++) { argumentsBuilder.Add(reader.ReadString()); } _formatArguments = argumentsBuilder.ToArrayAndFree(); } }
protected XmlSyntaxDiagnosticInfo(ObjectReader reader) : base(reader) { this.xmlErrorCode = (XmlParseErrorCode)reader.ReadCompressedUInt(); }
private XmlSyntaxDiagnosticInfo(ObjectReader reader) : base(reader) { _xmlErrorCode = (XmlParseErrorCode)reader.ReadCompressedUInt(); }