当前位置: 首页>>代码示例>>C#>>正文


C# ByteArraySegment类代码示例

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


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

示例1: TLV

 public TLV(byte[] bytes, int offset)
 {
     ByteArraySegment byteArraySegment = new ByteArraySegment(bytes, offset, 2);
     this.TypeLength = new TLVTypeLength(byteArraySegment);
     this.tlvData = new ByteArraySegment(bytes, offset, this.TypeLength.Length + 2);
     this.tlvData.Length = this.TypeLength.Length + 2;
 }
开发者ID:BGCX261,项目名称:znqq-svn-to-git,代码行数:7,代码来源:TLV.cs

示例2: ProbeRequestFrame

            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="bas">
            /// A <see cref="ByteArraySegment"/>
            /// </param>
            public ProbeRequestFrame (ByteArraySegment bas)
            {
                header = new ByteArraySegment (bas);

                FrameControl = new FrameControlField (FrameControlBytes);
                Duration = new DurationField (DurationBytes);
                DestinationAddress = GetAddress (0);
                SourceAddress = GetAddress (1);
                BssId = GetAddress (2);
                SequenceControl = new SequenceControlField (SequenceControlBytes);
				
				if(bas.Length > ProbeRequestFields.InformationElement1Position)
				{
                	//create a segment that just refers to the info element section
                	ByteArraySegment infoElementsSegment = new ByteArraySegment (bas.Bytes,
                    	(bas.Offset + ProbeRequestFields.InformationElement1Position),
                    	(bas.Length - ProbeRequestFields.InformationElement1Position));

                	InformationElements = new InformationElementList (infoElementsSegment);
				}
				else
				{
					InformationElements = new InformationElementList ();
				}
                //cant set length until after we have handled the information elements
                //as they vary in length
                header.Length = FrameSize;
            }
开发者ID:vishalishere,项目名称:packetnet,代码行数:34,代码来源:ProbeRequestFrame.cs

示例3: HandleTcpReceived

        internal void HandleTcpReceived(uint sequenceNumber, ByteArraySegment data)
        {
            var dataPosition = SequenceNumberToBytesReceived(sequenceNumber);
            if (dataPosition == BytesReceived)
            {
                OnDataReceived(data);
                BytesReceived += data.Length;
            }
            else
            {
                var dataArray = new byte[data.Length];
                Array.Copy(data.Bytes, data.Offset, dataArray, 0, data.Length);
                if (!_bufferedPackets.ContainsKey(dataPosition) ||
                    _bufferedPackets[dataPosition].Length < dataArray.Length)
                {
                    _bufferedPackets[dataPosition] = dataArray;
                }
            }

            long firstBufferedPosition;
            while (_bufferedPackets.Any() && ((firstBufferedPosition = _bufferedPackets.Keys.First()) <= BytesReceived))
            {
                var dataArray = _bufferedPackets[firstBufferedPosition];
                _bufferedPackets.Remove(firstBufferedPosition);

                var alreadyReceivedBytes = BytesReceived - firstBufferedPosition;
                Debug.Assert(alreadyReceivedBytes >= 0);

                if (alreadyReceivedBytes >= dataArray.Length) continue;
                var count = dataArray.Length - alreadyReceivedBytes;
                OnDataReceived(new ByteArraySegment(dataArray, (int) alreadyReceivedBytes, (int) count));
                BytesReceived += count;
            }
        }
开发者ID:ha-tam,项目名称:TeraDamageMeter,代码行数:34,代码来源:TcpConnection.cs

示例4: Test_Constructor_ConstructWithValues

            public void Test_Constructor_ConstructWithValues ()
            {
                AckFrame frame = new AckFrame (PhysicalAddress.Parse ("111111111111"));
                
                frame.FrameControl.ToDS = false;
                frame.FrameControl.FromDS = true;
                frame.FrameControl.MoreFragments = true;
                
                frame.Duration.Field = 0x1234;
                
                frame.UpdateFrameCheckSequence ();
                UInt32 fcs = frame.FrameCheckSequence;
                
                //serialize the frame into a byte buffer
                var bytes = frame.Bytes;
                var bas = new ByteArraySegment (bytes);

                //create a new frame that should be identical to the original
                AckFrame recreatedFrame = MacFrame.ParsePacket (bas) as AckFrame;
                recreatedFrame.UpdateFrameCheckSequence ();
                
                Assert.AreEqual (FrameControlField.FrameSubTypes.ControlACK, recreatedFrame.FrameControl.SubType);
                Assert.IsFalse (recreatedFrame.FrameControl.ToDS);
                Assert.IsTrue (recreatedFrame.FrameControl.FromDS);
                Assert.IsTrue (recreatedFrame.FrameControl.MoreFragments);
                
                Assert.AreEqual ("111111111111", recreatedFrame.ReceiverAddress.ToString ().ToUpper ());
                
                Assert.AreEqual (fcs, recreatedFrame.FrameCheckSequence);
            }
开发者ID:vishalishere,项目名称:packetnet,代码行数:30,代码来源:AckFrameTest.cs

示例5: FloodFiller

 public FloodFiller(ByteArraySegment skin, int skinwidth, int skinheight)
 {
     _Skin = skin;
     _Width = skinwidth;
     _Height = skinheight;
     _Fifo = new floodfill_t[FLOODFILL_FIFO_SIZE];
     _FillColor = _Skin.Data[_Skin.StartIndex]; // *skin; // assume this is the pixel to fill
 }
开发者ID:Memorix101,项目名称:SharpQuake,代码行数:8,代码来源:Model.cs

示例6: Test_Constructor_EmptyByteArray

            public void Test_Constructor_EmptyByteArray ()
            {
                ByteArraySegment bas = new ByteArraySegment (new Byte[0]);
                InformationElementList ieList = new InformationElementList (bas);

                Assert.AreEqual (0, ieList.Count);
                Assert.AreEqual (0, ieList.Length);
            }
开发者ID:vishalishere,项目名称:packetnet,代码行数:8,代码来源:InformationElementListTest.cs

示例7: StringTLV

		/// <summary>
		/// Create from a type and string value
		/// </summary>
		/// <param name="tlvType">
		/// A <see cref="TLVTypes"/>
		/// </param>
		/// <param name="StringValue">
		/// A <see cref="System.String"/>
		/// </param>
		public StringTLV(TLVTypes tlvType, string StringValue) {
			var bytes = new byte[TLVTypeLength.TypeLengthLength];
			var offset = 0;
			tlvData = new ByteArraySegment(bytes, offset, bytes.Length);

			Type = tlvType;
			this.StringValue = StringValue;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:17,代码来源:StringTLV.cs

示例8: IGMPv2Packet

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="bas">
		/// A <see cref="ByteArraySegment"/>
		/// </param>
		public IGMPv2Packet(ByteArraySegment bas) {
			// set the header field, header field values are retrieved from this byte array
			header = new ByteArraySegment(bas);
			header.Length = UdpFields.HeaderLength;

			// store the payload bytes
			payloadPacketOrData = new PacketOrByteArraySegment();
			payloadPacketOrData.TheByteArraySegment = header.EncapsulatedBytes();
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:15,代码来源:IGMPv2Packet.cs

示例9: Decoder

        public Decoder(int bufsize, long maxmsgsize)
            : base(bufsize)
        {
            m_maxmsgsize = maxmsgsize;
            m_tmpbuf = new ByteArraySegment(new byte[8]);

            //  At the beginning, read one byte and go to one_byte_size_ready state.
            NextStep (m_tmpbuf, 1, OneByteSizeReadyState);
        }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:9,代码来源:Decoder.cs

示例10: CtsFrame

            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="bas">
            /// A <see cref="ByteArraySegment"/>
            /// </param>
            public CtsFrame (ByteArraySegment bas)
            {
                header = new ByteArraySegment (bas);

                FrameControl = new FrameControlField (FrameControlBytes);
                Duration = new DurationField (DurationBytes);
                ReceiverAddress = GetAddress(0);
				
				header.Length = FrameSize;
            }
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:16,代码来源:CtsFrame.cs

示例11: SystemCapabilities

		/// <summary>
		/// Creates a System Capabilities TLV and sets the value
		/// </summary>
		/// <param name="capabilities">
		/// A bitmap containing the available System Capabilities
		/// </param>
		/// <param name="enabled">
		/// A bitmap containing the enabled System Capabilities
		/// </param>
		public SystemCapabilities(ushort capabilities, ushort enabled) {
			var length = TLVTypeLength.TypeLengthLength + SystemCapabilitiesLength + EnabledCapabilitiesLength;
			var bytes = new byte[length];
			var offset = 0;
			tlvData = new ByteArraySegment(bytes, offset, length);

			Type = TLVTypes.SystemCapabilities;
			Capabilities = capabilities;
			Enabled = enabled;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:19,代码来源:SystemCapabilities.cs

示例12: Test_Constructor_BufferTooShort

 public void Test_Constructor_BufferTooShort ()
 {
     //This IE will have and length of 5 but only three bytes of data
     Byte[] value = new Byte[] { 0x0, 0x5, 0x1, 0x2, 0x3 };
     ByteArraySegment bas = new ByteArraySegment (value);
     
     InformationElement infoElement = new InformationElement (bas);
     
     Assert.AreEqual (3, infoElement.ValueLength);
     Assert.AreEqual (3, infoElement.Value.Length);
 }
开发者ID:vishalishere,项目名称:packetnet,代码行数:11,代码来源:InformationElementTest.cs

示例13: NullDataFrame

            /// <summary>
            /// Initializes a new instance of the <see cref="PacketDotNet.Ieee80211.NullDataFrame"/> class.
            /// </summary>
            /// <param name='bas'>
            /// A <see cref="ByteArraySegment"/>
            /// </param>
            public NullDataFrame (ByteArraySegment bas)
            {
                header = new ByteArraySegment (bas);

                FrameControl = new FrameControlField (FrameControlBytes);
                Duration = new DurationField (DurationBytes);
                SequenceControl = new SequenceControlField (SequenceControlBytes);
                ReadAddresses ();
                
                header.Length = FrameSize;
            }
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:17,代码来源:NullDataFrame.cs

示例14: Test_Constructor_BufferLongerThanElement

 public void Test_Constructor_BufferLongerThanElement ()
 {
     //This IE will have and length of 2 but there are three bytes of data available,
     //the last one should be ignored
     Byte[] value = new Byte[] { 0x0, 0x2, 0x1, 0x2, 0x3 };
     ByteArraySegment bas = new ByteArraySegment (value);
     
     InformationElement infoElement = new InformationElement (bas);
     
     Assert.AreEqual (2, infoElement.ValueLength);
     Assert.AreEqual (2, infoElement.Value.Length);
 }
开发者ID:vishalishere,项目名称:packetnet,代码行数:12,代码来源:InformationElementTest.cs

示例15: V1Decoder

        /// <summary>
        /// Create a new V1Decoder with the given buffer-size, maximum-message-size and Endian-ness.
        /// </summary>
        /// <param name="bufsize">the buffer-size to give the contained buffer</param>
        /// <param name="maxMessageSize">the maximum message size. -1 indicates no limit.</param>
        /// <param name="endian">the Endianness to specify for it - either Big or Little</param>
        public V1Decoder(int bufsize, long maxMessageSize, Endianness endian)
            : base(bufsize, endian)
        {
            m_maxMessageSize = maxMessageSize;
            m_tmpbuf = new ByteArraySegment(new byte[8]);

            //  At the beginning, read one byte and go to one_byte_size_ready state.
            NextStep(m_tmpbuf, 1, OneByteSizeReadyState);

            m_inProgress = new Msg();
            m_inProgress.InitEmpty();
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:18,代码来源:V1Decoder.cs


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