• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MsgPack.SplittingStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MsgPack.SplittingStream的典型用法代码示例。如果您正苦于以下问题:C# SplittingStream类的具体用法?C# SplittingStream怎么用?C# SplittingStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SplittingStream类属于MsgPack命名空间,在下文中一共展示了SplittingStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestUnpackFixStr_0_AsString_Read_JustLength_Splitted

		public void TestUnpackFixStr_0_AsString_Read_JustLength_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xA0 }
					.Concat( Enumerable.Repeat( ( byte )'A', 0 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.IsTrue( unpacker.Read() );
#pragma warning disable 612,618
				var result = unpacker.Data;
#pragma warning restore 612,618
				Assert.IsTrue( result.HasValue );
				Assert.That( ( String )result.Value, Is.EqualTo( new String( 'A', 0 ) ) );
				Assert.That( result.Value.UnderlyingType, Is.EqualTo( typeof( String ) ) );

				// raw/str always can be byte[]
				var asBinary = ( byte[] )result.Value;
				var asString = ( String )result.Value;
				Assert.That( result.Value.IsTypeOf( typeof( string ) ).GetValueOrDefault() );
				Assert.That( result.Value.IsTypeOf( typeof( byte[] ) ).GetValueOrDefault() );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:26,代码来源:UnpackerTest.Raw.cs


示例2: TestRead_Int64MinValue_Splitted

		public void TestRead_Int64MinValue_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xD3, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.IsTrue( unpacker.Read() );
#pragma warning disable 612,618
				var result = unpacker.Data;
#pragma warning restore 612,618
				Assert.IsTrue( result.HasValue );
				Assert.That( ( System.Int64 )result.Value, Is.EqualTo( -9223372036854775808 ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:14,代码来源:UnpackerTest.Scalar.cs


示例3: TestByte_Splitted

		public void TestByte_Splitted()
		{
			var value = Byte.MaxValue;
			using( var output = new MemoryStream() )
			{
				Packer.Create( output ).Pack( value );
				output.Position = 0;
				using( var splitted = new SplittingStream( output ) )
				{
					var mpo = Unpacking.UnpackObject( splitted );
					Assert.AreEqual( value, ( Byte )mpo );
					Assert.AreEqual( value, mpo.AsByte() );
				}
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:15,代码来源:PackUnpackTest.Scalar.cs


示例4: TestRead_FixExt1_AndBinaryLengthIs1JustLength_Success_Splitted

		public void TestRead_FixExt1_AndBinaryLengthIs1JustLength_Success_Splitted()
		{
			var typeCode = ( byte )( Math.Abs( Environment.TickCount ) % 128 );
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xD4, typeCode }
					.Concat( Enumerable.Repeat( ( byte )0xFF, 1 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.IsTrue( unpacker.Read() );
#pragma warning disable 612,618
				var result = unpacker.Data;
#pragma warning restore 612,618
				Assert.IsTrue( result.HasValue );
				var actual = ( MessagePackExtendedTypeObject )result;
				Assert.That( actual.TypeCode, Is.EqualTo( typeCode ) );
				Assert.That( actual.Body, Is.Not.Null );
				Assert.That( actual.Body.Length, Is.EqualTo( 1 ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:23,代码来源:UnpackerTest.Ext.cs


示例5: TestUnpackBin32_65536_ReadString_TooShort_Splitted

		public void TestUnpackBin32_65536_ReadString_TooShort_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xC6, 0, 1, 0, 0 }
					.Concat( Enumerable.Repeat( ( byte )'A', 65535 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				String result;
				Assert.Throws<InvalidMessagePackStreamException>( () => unpacker.ReadString( out result ) );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:15,代码来源:UnpackerTest.Raw.cs


示例6: TestUnpackStr8_1_AsString_Read_TooShort_Splitted

		public void TestUnpackStr8_1_AsString_Read_TooShort_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xD9, 1 }
					.Concat( Enumerable.Repeat( ( byte )'A', 0 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.Throws<InvalidMessagePackStreamException>( () => unpacker.Read() );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:14,代码来源:UnpackerTest.Raw.cs


示例7: TestUnpackBin32_65535_AsBinary_Read_TooShort_Splitted

		public void TestUnpackBin32_65535_AsBinary_Read_TooShort_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xC6, 0, 0, 0xFF, 0xFF }
					.Concat( Enumerable.Repeat( ( byte )0xFF, 65534 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.Throws<InvalidMessagePackStreamException>( () => unpacker.Read() );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:14,代码来源:UnpackerTest.Raw.cs


示例8: TestUnpackBin16_256_ReadBinary_TooShort_Splitted

		public void TestUnpackBin16_256_ReadBinary_TooShort_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xC5, 1, 0 }
					.Concat( Enumerable.Repeat( ( byte )0xFF, 255 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Byte[] result;
				Assert.Throws<InvalidMessagePackStreamException>( () => unpacker.ReadBinary( out result ) );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:15,代码来源:UnpackerTest.Raw.cs


示例9: TestUnpackStr32_0_AsBinary_Read_HasExtra_Splitted

		public void TestUnpackStr32_0_AsBinary_Read_HasExtra_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xDB, 0, 0, 0, 0 }
					.Concat( Enumerable.Repeat( ( byte )0xFF, 1 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.IsTrue( unpacker.Read() );
#pragma warning disable 612,618
				var result = unpacker.Data;
#pragma warning restore 612,618
				Assert.IsTrue( result.HasValue );

				// raw/str always can be byte[]
				var asBinary = ( byte[] )result.Value;
				var asString = ( String )result.Value;
				Assert.That( result.Value.IsTypeOf( typeof( string ) ).GetValueOrDefault() );
				Assert.That( result.Value.IsTypeOf( typeof( byte[] ) ).GetValueOrDefault() );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:24,代码来源:UnpackerTest.Raw.cs


示例10: TestReadNullableDoubleAsync_DoubleNegativeZero_Splitted

		public async Task TestReadNullableDoubleAsync_DoubleNegativeZero_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCB, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Double? result;
				var ret = await unpacker.ReadNullableDoubleAsync();
				Assert.IsTrue( ret.Success );
				result = ret.Value;
				Assert.That( ( -0.0 ).Equals( result.Value ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:13,代码来源:UnpackerTest.Scalar.cs


示例11: TestReadDoubleAsync_DoubleEpsilon_Splitted

		public async Task TestReadDoubleAsync_DoubleEpsilon_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Double result;
				var ret = await unpacker.ReadDoubleAsync();
				Assert.IsTrue( ret.Success );
				result = ret.Value;
				Assert.That( Double.Epsilon.Equals( result ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:13,代码来源:UnpackerTest.Scalar.cs


示例12: TestReadNullableDoubleAsync_DoubleMaxValue_Splitted

		public async Task TestReadNullableDoubleAsync_DoubleMaxValue_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCB, 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Double? result;
				var ret = await unpacker.ReadNullableDoubleAsync();
				Assert.IsTrue( ret.Success );
				result = ret.Value;
				Assert.That( Double.MaxValue.Equals( result.Value ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:13,代码来源:UnpackerTest.Scalar.cs


示例13: TestReadSingleAsync_SingleNegativeInfinity_Splitted

		public async Task TestReadSingleAsync_SingleNegativeInfinity_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCA, 0xFF, 0x80, 0x00, 0x00 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Single result;
				var ret = await unpacker.ReadSingleAsync();
				Assert.IsTrue( ret.Success );
				result = ret.Value;
				Assert.That( Single.IsNegativeInfinity( result ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:13,代码来源:UnpackerTest.Scalar.cs


示例14: TestReadAsync_SingleNaNNegativeMaxValue_Splitted

		public async Task TestReadAsync_SingleNaNNegativeMaxValue_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCA, 0xFF, 0xFF, 0xFF, 0xFF } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.IsTrue( await unpacker.ReadAsync() );
#pragma warning disable 612,618
				var result = unpacker.Data;
#pragma warning restore 612,618
				Assert.IsTrue( result.HasValue );
				Assert.That( Single.IsNaN( ( System.Single )result.Value ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:14,代码来源:UnpackerTest.Scalar.cs


示例15: TestReadNullableSingleAsync_SingleNaNPositiveMaxValue_Splitted

		public async Task TestReadNullableSingleAsync_SingleNaNPositiveMaxValue_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCA, 0x7F, 0xFF, 0xFF, 0xFF } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Single? result;
				var ret = await unpacker.ReadNullableSingleAsync();
				Assert.IsTrue( ret.Success );
				result = ret.Value;
				Assert.That( Single.IsNaN( result.Value ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:13,代码来源:UnpackerTest.Scalar.cs


示例16: TestRead_PlusOne_Splitted

		public void TestRead_PlusOne_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0x1 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Assert.IsTrue( unpacker.Read() );
#pragma warning disable 612,618
				var result = unpacker.Data;
#pragma warning restore 612,618
				Assert.IsTrue( result.HasValue );
				Assert.That( ( System.UInt64 )result.Value, Is.EqualTo( 1 ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:14,代码来源:UnpackerTest.Scalar.cs


示例17: TestReadUInt64_PlusOne_Splitted

		public void TestReadUInt64_PlusOne_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0x1 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				UInt64 result;
				Assert.IsTrue( unpacker.ReadUInt64( out result ) );
				Assert.That( result, Is.EqualTo( 1 ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:11,代码来源:UnpackerTest.Scalar.cs


示例18: TestReadNullableInt64_NegativeFixNumMinValue_Splitted

		public void TestReadNullableInt64_NegativeFixNumMinValue_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xE0 } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Int64? result;
				Assert.IsTrue( unpacker.ReadNullableInt64( out result ) );
				Assert.That( result.Value, Is.EqualTo( -32 ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:11,代码来源:UnpackerTest.Scalar.cs


示例19: TestUnpackBin16_255_ReadBinary_HasExtra_Splitted

		public void TestUnpackBin16_255_ReadBinary_HasExtra_Splitted()
		{
			using( var buffer =
				new MemoryStream( 
					new byte[] { 0xC5, 0, 0xFF }
					.Concat( Enumerable.Repeat( ( byte )0xFF, 256 ) ).ToArray()
				)
			)
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Byte[] result;
				Assert.IsTrue( unpacker.ReadBinary( out result ) );
				Assert.That( result, Is.EqualTo( Enumerable.Repeat( 0xFF, 255 ).ToArray() ) );
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:16,代码来源:UnpackerTest.Raw.cs


示例20: TestReadDoubleAsync_DoubleNaNNegativeMaxValue_Splitted

		public async Task TestReadDoubleAsync_DoubleNaNNegativeMaxValue_Splitted()
		{
			using( var buffer = new MemoryStream( new byte[] { 0xCB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } ) )
			using( var splitted = new SplittingStream( buffer ) )
			using( var unpacker = Unpacker.Create( splitted ) )
			{
				Double result;
				var ret = await unpacker.ReadDoubleAsync();
				Assert.IsTrue( ret.Success );
				result = ret.Value;
				Assert.That( Double.IsNaN( result ) );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:13,代码来源:UnpackerTest.Scalar.cs



注:本文中的MsgPack.SplittingStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Reflection.TracingILGenerator类代码示例发布时间:2022-05-26
下一篇:
C# MsgPack.ItemsUnpacker类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap