public void StringInUtf8CanBeReaded() { // Arrange const string s = "hello world"; var data = Encoding.UTF8.GetBytes(s); var size = BitConverter.GetBytes(data.Length); var finalData = new List <byte>(); foreach (byte b in size) { finalData.Add(b); } foreach (byte b in data) { finalData.Add(b); } // Act var stream = new DeserializationStream(finalData.ToArray()); var result = stream.ReadUtf8WithSizePrefix(); // Assert result.Should().Be(s); stream.Offset.Should().Be(finalData.Count); }
protected override string DeserializeInternal(DeserializationStream stream, Type sourceType) { return(stream.ReadUtf8WithSizePrefix()); }
protected override Uri DeserializeInternal(DeserializationStream stream, Type sourceType) { string absoluteUri = stream.ReadUtf8WithSizePrefix(); return(new Uri(absoluteUri)); }