當前位置: 首頁>>代碼示例>>C#>>正文


C# MsgPack.ItemsUnpacker類代碼示例

本文整理匯總了C#中MsgPack.ItemsUnpacker的典型用法代碼示例。如果您正苦於以下問題:C# ItemsUnpacker類的具體用法?C# ItemsUnpacker怎麽用?C# ItemsUnpacker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ItemsUnpacker類屬於MsgPack命名空間,在下文中一共展示了ItemsUnpacker類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestSkip_FalseValue

		public void TestSkip_FalseValue()
		{
			var binary = new byte[]{ 0xC2, 0xC2 };
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例2: SubtreeUnpacker

		private SubtreeUnpacker( ItemsUnpacker root, SubtreeUnpacker parent )
		{
			Contract.Assert( root != null );
			Contract.Assert( root.IsArrayHeader || root.IsMapHeader );
			this._root = root;
			this._parent = parent;
			this._unpacked = new Stack<long>( 2 );

			this._itemsCount = new Stack<long>( 2 );
			this._isMap = new Stack<bool>( 2 );

			if ( root.ItemsCount > 0 )
			{
				this._itemsCount.Push( root.ItemsCount * ( root.IsMapHeader ? 2 : 1 ) );
				this._unpacked.Push( 0 );
				this._isMap.Push( root.IsMapHeader );
			}
		}
開發者ID:purplecow,項目名稱:msgpack-cli,代碼行數:18,代碼來源:SubtreeUnpacker.cs

示例3: SubtreeUnpacker

		private SubtreeUnpacker( ItemsUnpacker root, SubtreeUnpacker parent )
		{
#if DEBUG && !UNITY_ANDROID && !UNITY_IPHONE
			Contract.Assert( root != null );
			Contract.Assert( root.IsArrayHeader || root.IsMapHeader );
#endif // DEBUG && !UNITY_ANDROID && !UNITY_IPHONE
			this._root = root;
			this._parent = parent;
			this._unpacked = new Stack<long>( 2 );

			this._itemsCount = new Stack<long>( 2 );
			this._isMap = new Stack<bool>( 2 );

			if ( root.ItemsCount > 0 )
			{
				this._itemsCount.Push( root.InternalItemsCount * ( ( int )root.InternalCollectionType ) );
				this._unpacked.Push( 0 );
				this._isMap.Push( root.InternalCollectionType == ItemsUnpacker.CollectionType.Map );
			}
		}
開發者ID:nagyist,項目名稱:msgpack-cli,代碼行數:20,代碼來源:SubtreeUnpacker.cs

示例4: SubtreeUnpacker

		private SubtreeUnpacker( ItemsUnpacker root, SubtreeUnpacker parent )
		{
#if DEBUG
			Contract.Assert( root != null, "root != null" );
			Contract.Assert( root.IsArrayHeader || root.IsMapHeader, "root.IsArrayHeader || root.IsMapHeader" );
#endif // DEBUG
			this._root = root;
			this._parent = parent;
			this._unpacked = new Int64Stack( 2 );

			this._itemsCount = new Int64Stack( 2 );
			this._isMap = new BooleanStack( 2 );

			if ( root.ItemsCount > 0 )
			{
				this._itemsCount.Push( root.InternalItemsCount * ( ( int )root.InternalCollectionType ) );
				this._unpacked.Push( 0 );
				this._isMap.Push( root.InternalCollectionType == ItemsUnpacker.CollectionType.Map );
			}

			this._state = State.InHead;
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:22,代碼來源:SubtreeUnpacker.cs

示例5: TestSkip_Ext16_Zero

		public void TestSkip_Ext16_Zero()
		{
			var binary = new byte[] { 0xC8 }.Concat( BitConverter.GetBytes( ( ushort )0x0 ).Reverse() ).Concat( new byte[] { 0x7F } ).Concat( new byte[] { 0xC2 } ).ToArray();
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例6: TestSkip_Ext8_Max

		public void TestSkip_Ext8_Max()
		{
			var binary = new byte[] { 0xC7 }.Concat( new byte[] { 0xFF } ).Concat( new byte[] { 0x7F } ).Concat( Enumerable.Repeat( 0x41, 0xFF ).Select( i => ( byte )i ) ).Concat( new byte[] { 0xC2 } ).ToArray();
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例7: TestSkip_FixExt16

		public void TestSkip_FixExt16()
		{
			var binary = new byte[]{ 0xD8, 0x7F, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0xC2 };
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例8: TestSkipAsync_Ext32_Max

		public async Task TestSkipAsync_Ext32_Max()
		{
			var binary = new byte[] { 0xC9 }.Concat( BitConverter.GetBytes( ( uint )0x10001 ).Reverse() ).Concat( new byte[] { 0x7F } ).Concat( Enumerable.Repeat( 0x41, 0x10001 ).Select( i => ( byte )i ) ).Concat( new byte[] { 0xC2 } ).ToArray();
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = await target.SkipAsync();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例9: TestSkipAsync_Ext8_Zero

		public async Task TestSkipAsync_Ext8_Zero()
		{
			var binary = new byte[] { 0xC7 }.Concat( new byte[] { 0x0 } ).Concat( new byte[] { 0x7F } ).Concat( new byte[] { 0xC2 } ).ToArray();
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = await target.SkipAsync();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例10: TestSkipAsync_FixExt8

		public async Task TestSkipAsync_FixExt8()
		{
			var binary = new byte[]{ 0xD7, 0x7F, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0xC2 };
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, PackerUnpackerStreamOptions.None ) )
			{
				var result = await target.SkipAsync();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:msgpack,項目名稱:msgpack-cli,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例11: TestBin32_Min

		public void TestBin32_Min()
		{
			var binary = new byte[] { 0xC6 }.Concat( BitConverter.GetBytes( ( uint )0x10000 ).Reverse() ).Concat( Enumerable.Repeat( 0x41, 0x10000 ).Select( i => ( byte )i ) ).Concat( new byte[] { 0xC2 } ).ToArray();
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, false ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:gezidan,項目名稱:ZYSOCKET,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例12: TestBin8_Zero

		public void TestBin8_Zero()
		{
			var binary = new byte[] { 0xC4 }.Concat( new byte[] { 0x0 } ).Concat( new byte[] { 0xC2 } ).ToArray();
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, false ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:gezidan,項目名稱:ZYSOCKET,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs

示例13: TestFixExt4

		public void TestFixExt4()
		{
			var binary = new byte[]{ 0xD6, 0x7F, 0x04, 0x03, 0x02, 0x01, 0xC2 };
			using ( var buffer = new MemoryStream( binary ) )
			using ( var target = new ItemsUnpacker( buffer, false ) )
			{
				var result = target.Skip();
				Assert.That( result, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				Assert.That( buffer.Position, Is.EqualTo( binary.Length - 1 /* minus centinel byte */ ) );
				// Verify centinel value still exists in the stream.
				Assert.That( buffer.ReadByte(), Is.EqualTo( 0xC2 ) );
			}
		}
開發者ID:gezidan,項目名稱:ZYSOCKET,代碼行數:13,代碼來源:UnpackerTest.Skip.Variations.cs


注:本文中的MsgPack.ItemsUnpacker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。