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


C# ByteBuffer类代码示例

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


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

示例1: ExtNegotiation

 /*
 internal ExtNegotiation(BinaryReader din, int len)
 {
     int uidLen = din.ReadUInt16();
     this.asuid = AAssociateRQAC.ReadASCII(din, uidLen);
     this.m_info = new byte[len - uidLen - 2];
     din.BaseStream.Read( m_info, 0, m_info.Length);
 }
 */
 internal ExtNegotiation(ByteBuffer bb, int len)
 {
     int uidLen = bb.ReadInt16();
     this.asuid = bb.ReadString(uidLen);
     this.m_info = new byte[len - uidLen - 2];
     bb.Read( m_info, 0, m_info.Length );
 }
开发者ID:sleighter,项目名称:dicom-sharp,代码行数:16,代码来源:ExtNegotiation.cs

示例2: Read

		public int Read (ByteBuffer buffer)
		{
			int offset = buffer.Position () + buffer.ArrayOffset ();
			int num2 = s.Read (buffer.Array (), offset, (buffer.Limit () + buffer.ArrayOffset ()) - offset);
			buffer.Position (buffer.Position () + num2);
			return num2;
		}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:7,代码来源:FileChannel.cs

示例3: ReadMessageAsync

        public static async Task<WebSocketMessage> ReadMessageAsync(WebSocket webSocket, byte[] buffer, int maxMessageSize)
        {
            ArraySegment<byte> arraySegment = new ArraySegment<byte>(buffer);

            WebSocketReceiveResult receiveResult = await webSocket.ReceiveAsync(arraySegment, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
            // special-case close messages since they might not have the EOF flag set
            if (receiveResult.MessageType == WebSocketMessageType.Close)
            {
                return new WebSocketMessage(null, WebSocketMessageType.Close);
            }

            if (receiveResult.EndOfMessage)
            {
                // we anticipate that single-fragment messages will be common, so we optimize for them
                switch (receiveResult.MessageType)
                {
                    case WebSocketMessageType.Binary:
                        return new WebSocketMessage(BufferSliceToByteArray(buffer, receiveResult.Count), WebSocketMessageType.Binary);

                    case WebSocketMessageType.Text:
                        return new WebSocketMessage(BufferSliceToString(buffer, receiveResult.Count), WebSocketMessageType.Text);

                    default:
                        throw new Exception("This code path should never be hit.");
                }
            }
            else
            {
                // for multi-fragment messages, we need to coalesce
                ByteBuffer bytebuffer = new ByteBuffer(maxMessageSize);
                bytebuffer.Append(BufferSliceToByteArray(buffer, receiveResult.Count));
                WebSocketMessageType originalMessageType = receiveResult.MessageType;

                while (true)
                {
                    // loop until an error occurs or we see EOF
                    receiveResult = await webSocket.ReceiveAsync(arraySegment, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
                    if (receiveResult.MessageType != originalMessageType)
                    {
                        throw new InvalidOperationException("Incorrect message type");
                    }

                    bytebuffer.Append(BufferSliceToByteArray(buffer, receiveResult.Count));
                    if (receiveResult.EndOfMessage)
                    {
                        switch (receiveResult.MessageType)
                        {
                            case WebSocketMessageType.Binary:
                                return new WebSocketMessage(bytebuffer.GetByteArray(), WebSocketMessageType.Binary);

                            case WebSocketMessageType.Text:
                                return new WebSocketMessage(bytebuffer.GetString(), WebSocketMessageType.Text);

                            default:
                                throw new Exception("This code path should never be hit.");
                        }
                    }
                }
            }
        }
开发者ID:TerenceLewis,项目名称:SignalR,代码行数:60,代码来源:WebSocketMessageReader.cs

示例4: serialize

            public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje)
            {
                var obj = (DebugProperty) obje;

                serializer.serialize(buffer, obj.key);
                serializer.serialize(buffer, obj.value);
            }
开发者ID:khangnguyen,项目名称:robocode,代码行数:7,代码来源:DebugProperty.cs

示例5: GetBytesFromCString

 public static byte[] GetBytesFromCString(string cStr, DataCoding dataCoding)
 {
     if (cStr == null) { throw new ArgumentNullException("cStr"); }
     if (cStr.Length == 0) { return new byte[] { 0x00 }; }
     byte[] bytes = null;
     switch (dataCoding)
     {
         case DataCoding.ASCII:
             bytes = System.Text.Encoding.ASCII.GetBytes(cStr);
             break;
         case DataCoding.Latin1:
             bytes = Latin1Encoding.GetBytes(cStr);
             break;
         case DataCoding.UCS2:
             bytes = System.Text.Encoding.Unicode.GetBytes(cStr);
             break;
         case DataCoding.SMSCDefault:
             bytes = SMSCDefaultEncoding.GetBytes(cStr);
             break;
         default:
             throw new SmppException(SmppErrorCode.ESME_RUNKNOWNERR, "Unsupported encoding");
     }
     ByteBuffer buffer = new ByteBuffer(bytes, bytes.Length + 1);
     buffer.Append(new byte[] { 0x00 }); //Append a null charactor a the end
     return buffer.ToBytes();
 }
开发者ID:James226,项目名称:SMSWeb,代码行数:26,代码来源:SMPPEncodingUtil.cs

示例6: DicomAttributeMultiValueText

        internal DicomAttributeMultiValueText(DicomTag tag, ByteBuffer item)
            : base(tag)
        {
            string valueArray;

            valueArray = item.GetString();

            // store the length before removing pad chars
            StreamLength = (uint) valueArray.Length;

            // Saw some Osirix images that had padding on SH attributes with a null character, just
            // pull them out here.
			// Leading and trailing space characters are non-significant in all multi-valued VRs,
			// so pull them out here as well since some devices seem to pad UI attributes with spaces too.
            valueArray = valueArray.Trim(new [] {tag.VR.PadChar, '\0', ' '});

            if (valueArray.Length == 0)
            {
                _values = new string[0];
                Count = 1;
                StreamLength = 0;
            }
            else
            {
                _values = valueArray.Split(new char[] {'\\'});

                Count = (long) _values.Length;
                StreamLength = (uint) valueArray.Length;
            }
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:30,代码来源:DicomAttributeMultiValueText.cs

示例7: WriteIteratorScopes

		private void WriteIteratorScopes(Function function)
		{
			if (function.IteratorScopes.Count == 0)
				return;

			var buffer = new ByteBuffer();
			buffer.WriteByte(4);
			buffer.WriteByte(1);
			buffer.Align(4);

			buffer.WriteByte(4);
			buffer.WriteByte(3);
			buffer.Align(4);

			var scopes = function.IteratorScopes;

			buffer.WriteInt32(scopes.Count * 8 + 12);
			buffer.WriteInt32(scopes.Count);

			foreach (var scope in scopes)
			{
				buffer.WriteInt32(scope.Offset);
				buffer.WriteInt32(scope.Offset + scope.Length);
			}

			pdb.SetSymAttribute(function.Token, "MD2", buffer.length, buffer.buffer);
		}
开发者ID:ArsenShnurkov,项目名称:SyntaxTree.Pdb,代码行数:27,代码来源:PdbWriter.cs

示例8: Allocate

		/// <summary>
		/// Allocates a new byte buffer.
		/// The new buffer's position will be zero, its limit will be its capacity, 
		/// and its mark will be undefined. 
		/// It will have a backing array, and its array offset will be zero. 
		/// </summary>
		/// <param name="capacity"></param>
		/// <returns></returns>
		public static ByteBuffer Allocate(int capacity)
		{
			MemoryStream ms = new MemoryStream(capacity);
			ByteBuffer buffer = new ByteBuffer(ms);
			buffer.Limit = capacity;
			return buffer;
		}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:15,代码来源:ByteBuffer.cs

示例9: serialize

		override public void serialize(ByteBuffer bu)
		{
			base.serialize(bu)
			bu.writeUnsignedInt8(byCmd);
			bu.writeUnsignedInt8(byParam);
			bu.writeUnsignedInt32(dwTimestamp);
		}
开发者ID:quinsmpang,项目名称:Tools,代码行数:7,代码来源:NullUserCmd.cs

示例10: derialize

		override public void derialize(ByteBuffer bu)
		{
			base.derialize(bu)
			bu.readUnsignedInt8(ref byCmd);
			bu.readUnsignedInt8(ref byParam);
			bu.readUnsignedInt32(ref dwTimestamp);
		}
开发者ID:quinsmpang,项目名称:Tools,代码行数:7,代码来源:NullUserCmd.cs

示例11: OnDecode

        protected override void OnDecode(ByteBuffer buffer, int count)
        {
            if (count-- > 0)
            {
                this.Durable = AmqpCodec.DecodeBoolean(buffer);
            }

            if (count-- > 0)
            {
                this.Priority = AmqpCodec.DecodeUByte(buffer);
            }

            if (count-- > 0)
            {
                this.Ttl = AmqpCodec.DecodeUInt(buffer);
            }

            if (count-- > 0)
            {
                this.FirstAcquirer = AmqpCodec.DecodeBoolean(buffer);
            }

            if (count-- > 0)
            {
                this.DeliveryCount = AmqpCodec.DecodeUInt(buffer);
            }
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:27,代码来源:Header.cs

示例12: Find

        int Find(byte[] prefix, ByteBuffer key)
        {
            var left = 0;
            var right = _keyvalues.Length;
            var keyBytes = _keyBytes;
            while (left < right)
            {
                var middle = (left + right) / 2;
                int currentKeyOfs = _keyvalues[middle].KeyOffset;
                int currentKeyLen = _keyvalues[middle].KeyLength;
                var result = BitArrayManipulation.CompareByteArray(prefix, 0, prefix.Length,
                                                                   keyBytes, currentKeyOfs, Math.Min(currentKeyLen, prefix.Length));
                if (result == 0)
                {
                    result = BitArrayManipulation.CompareByteArray(key.Buffer, key.Offset, key.Length,
                                                                   keyBytes, currentKeyOfs + prefix.Length, currentKeyLen - prefix.Length);
                    if (result == 0)
                    {
                        return middle * 2 + 1;
                    }
                }
                if (result < 0)
                {
                    right = middle;
                }
                else
                {
                    left = middle + 1;
                }

            }
            return left * 2;
        }
开发者ID:Xamarui,项目名称:BTDB,代码行数:33,代码来源:BTreeLeafComp.cs

示例13: allocate

 public static ByteBuffer allocate(int capacity)
 {
     ByteBuffer b = new ByteBuffer();
     b.buffer = new byte[capacity];
     b.limit = 0;
     return b;
 }
开发者ID:BraynStorm,项目名称:Tanks,代码行数:7,代码来源:ByteBuffer.cs

示例14: Find

 int Find(byte[] prefix, ByteBuffer key)
 {
     var left = 0;
     var right = _keys.Length;
     while (left < right)
     {
         var middle = (left + right) / 2;
         var currentKey = _keys[middle];
         var result = BitArrayManipulation.CompareByteArray(prefix, prefix.Length,
                                                            currentKey, Math.Min(currentKey.Length, prefix.Length));
         if (result == 0)
         {
             result = BitArrayManipulation.CompareByteArray(key.Buffer, key.Offset, key.Length,
                                                            currentKey, prefix.Length, currentKey.Length - prefix.Length);
         }
         if (result < 0)
         {
             right = middle;
         }
         else
         {
             left = middle + 1;
         }
     }
     return left;
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:26,代码来源:BTreeBranch.cs

示例15: NESSoftReset

		public override void NESSoftReset()
		{
			lock_regs = false;
			cur_reg = 0;
			regs = new ByteBuffer(4);
			base.NESSoftReset();
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:7,代码来源:Mapper045.cs


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