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


C# ByteBuffer.Get方法代码示例

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


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

示例1: GetObject

        public static object GetObject(int type, int numel, ByteBuffer buf)
        {
            switch (type) {
                case CHAR:
                    byte[] strBytes = new byte[numel];
                    buf.Get(ref strBytes);
                    System.Text.Encoding encoding = buf.Encoding;
                    string val = encoding.GetString(strBytes, 0, strBytes.Length);
                    return val;

                case INT8:
                    goto case UINT8;
                case UINT8:
                    byte[] int8array = new byte[numel];
                    buf.Get(ref int8array);
                    return (object)int8array;

                case INT16:
                    goto case UINT16;
                case UINT16:
                    short[] int16array = new short[numel];
                    // The following would be faster, but DOES NOT
                    // increment the position of the original ByteBuffer!!!
                    // buf.asShortBuffer().get(int16array);
                    for (int i = 0; i < numel; i++)
                        int16array[i] = buf.GetShort();
                    return (object)int16array;

                case INT32:
                    goto case UINT32;
                case UINT32:
                    int[] int32array = new int[numel];
                    for (int i = 0; i < numel; i++)
                        int32array[i] = buf.GetInt();
                    return (object)int32array;

                case INT64:
                    goto case UINT64;
                case UINT64:
                    long[] int64array = new long[numel];
                    for (int i = 0; i < numel; i++)
                        int64array[i] = buf.GetLong();
                    return (object)int64array;

                case FLOAT32:
                    float[] float32array = new float[numel];
                    for (int i = 0; i < numel; i++)
                        float32array[i] = buf.GetFloat();
                    return (object)float32array;

                case FLOAT64:
                    double[] float64array = new double[numel];
                    for (int i = 0; i < numel; i++)
                        float64array[i] = buf.GetDouble();
                    return (object)float64array;

                default:
                    return null;
            }
        }
开发者ID:gbarresi,项目名称:buffer_bci,代码行数:60,代码来源:DataType.cs

示例2: ReadFrom

        public static ProducerRequest ReadFrom(ByteBuffer buffer)
        {
            var versionId = buffer.GetShort();
            var correlationId = buffer.GetInt();
            var clientId = ApiUtils.ReadShortString(buffer);
            var requiredAcks = buffer.GetShort();
            var ackTimeoutMs = buffer.GetInt();

            // built the topic structure
            var topicCount = buffer.GetInt();
            var partitionDataPairs = Enumerable.Range(1, topicCount).SelectMany(_ =>
            {
                // process topic
                var topic = ApiUtils.ReadShortString(buffer);
                var partitionCount = buffer.GetInt();
                return Enumerable.Range(1, partitionCount).Select(__ =>
                {
                    var partition = buffer.GetInt();
                    var messagesSetSize = buffer.GetInt();
                    var messageSetBuffer = new byte[messagesSetSize];
                    buffer.Get(messageSetBuffer, 0, messagesSetSize);
                    return Tuple.Create(
                        new TopicAndPartition(topic, partition),
                        new ByteBufferMessageSet(ByteBuffer.Wrap(messageSetBuffer)));
                });
            });
            return new ProducerRequest(versionId, correlationId, clientId, requiredAcks, ackTimeoutMs, partitionDataPairs.ToDictionary(k => k.Item1, v => v.Item2));
        }
开发者ID:Cnova,项目名称:kafka-net,代码行数:28,代码来源:ProducerRequest.cs

示例3: CanHandleData

 public bool CanHandleData(ByteBuffer data)
 {
     if (data.Limit == 0)
         return false;// Empty buffer
     byte first = data.Get();
     bool result = ((first & 0x0f) == VideoCodec.H263.Id);
     data.Rewind();
     return result;
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:9,代码来源:SorensonVideo.cs

示例4: __has_identifier

        protected static bool __has_identifier(ByteBuffer bb, string ident)
        {
            if (ident.Length != FlatBufferConstants.FileIdentifierLength)
                throw new ArgumentException("FlatBuffers: file identifier must be length " + FlatBufferConstants.FileIdentifierLength, "ident");

            for (var i = 0; i < FlatBufferConstants.FileIdentifierLength; i++)
            {
                if (ident[i] != (char)bb.Get(bb.position() + sizeof(int) + i)) return false;
            }

            return true;
        }
开发者ID:rdumusc,项目名称:flatbuffers,代码行数:12,代码来源:Table.cs

示例5: GetLong

 /// <summary>
 /// Reads an LEB128-64b9B ZigZag encoded 64 bit integer (<see cref="long"/>) value from the given buffer.
 /// </summary>
 /// <param name="buffer">The buffer to read from.</param>
 /// <returns>The value read from the buffer.</returns>
 public static long GetLong(ByteBuffer buffer)
 {
     long v = buffer.Get();
     long value = v & 0x7F;
     if ((v & 0x80) != 0)
     {
         v = buffer.Get();
         value |= (v & 0x7F) << 7;
         if ((v & 0x80) != 0)
         {
             v = buffer.Get();
             value |= (v & 0x7F) << 14;
             if ((v & 0x80) != 0)
             {
                 v = buffer.Get();
                 value |= (v & 0x7F) << 21;
                 if ((v & 0x80) != 0)
                 {
                     v = buffer.Get();
                     value |= (v & 0x7F) << 28;
                     if ((v & 0x80) != 0)
                     {
                         v = buffer.Get();
                         value |= (v & 0x7F) << 35;
                         if ((v & 0x80) != 0)
                         {
                             v = buffer.Get();
                             value |= (v & 0x7F) << 42;
                             if ((v & 0x80) != 0)
                             {
                                 v = buffer.Get();
                                 value |= (v & 0x7F) << 49;
                                 if ((v & 0x80) != 0)
                                 {
                                     v = buffer.Get();
                                     value |= v << 56;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     value = (value >> 1) ^ (-(value & 1));
     return value;
 }
开发者ID:qooroo,项目名称:HdrHistogram.NET,代码行数:52,代码来源:ZigZagEncoding.cs

示例6: GetVideoCodec

        /// <summary>
        /// Create and return new video codec applicable for byte buffer data
        /// </summary>
        /// <param name="data">Byte buffer data.</param>
        /// <returns>Video codec.</returns>
        public IVideoStreamCodec GetVideoCodec(ByteBuffer data)
        {
            IVideoStreamCodec result = null;
            //get the codec identifying byte
            int codecId = data.Get() & 0x0f;
            switch (codecId)
            {
                case 2: //sorenson 
                    result = new SorensonVideo();
                    break;
                case 3: //screen video
                    result = new ScreenVideo();
                    break;
                case 7: //avc/h.264 video
                    result = new AVCVideo();
                    break;
            }
            data.Rewind();
            if (result == null)
            {
                IVideoStreamCodec codec;
                foreach (IVideoStreamCodec storedCodec in _codecs)
                {
                    // XXX: this is a bit of a hack to create new instances of the
                    // configured video codec for each stream
                    try
                    {
                        codec = Activator.CreateInstance(storedCodec.GetType()) as IVideoStreamCodec;
                    }
                    catch (Exception ex)
                    {
                        log.Error("Could not create video codec instance.", ex);
                        continue;
                    }

                    log.Info("Trying codec " + codec);
                    if (codec.CanHandleData(data))
                    {
                        result = codec;
                        break;
                    }
                }
            }
            return result;
        }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:50,代码来源:VideoCodecFactory.cs

示例7: VideoData

		/// <summary>
		/// Initializes a new instance of the VideoData class.
		/// </summary>
		/// <param name="data">VideoData buffer.</param>
		public VideoData(ByteBuffer data)
			: base(EventType.STREAM_DATA) {
			_dataType = Constants.TypeVideoData;
			_data = data;
			if (_data != null && _data.Limit > 0) {
				long oldPos = _data.Position;
				int firstByte = (data.Get()) & 0xff;
				data.Position = oldPos;
				int frameType = (firstByte & IOConstants.MASK_VIDEO_FRAMETYPE) >> 4;
				if (frameType == IOConstants.FLAG_FRAMETYPE_KEYFRAME)
					_frameType = FrameType.Keyframe;
				else if (frameType == IOConstants.FLAG_FRAMETYPE_INTERFRAME)
					_frameType = FrameType.Interframe;
				else if (frameType == IOConstants.FLAG_FRAMETYPE_DISPOSABLE)
					_frameType = FrameType.DisposableInterframe;
				else
					_frameType = FrameType.Unknown;
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:23,代码来源:VideoData.cs

示例8: AddData

 public bool AddData(ByteBuffer data)
 {
     if (data.Limit == 0)
         return false;// Empty buffer
     if (!CanHandleData(data))
         return false;
     byte first = data.Get();
     data.Rewind();
     if ((first & 0xf0) != VideoCodec.FLV_FRAME_KEY)
         return true;// Not a keyframe
     // Store last keyframe
     _dataCount = data.Limit;
     if (_blockSize < _dataCount)
     {
         _blockSize = _dataCount;
         _blockData = new byte[_blockSize];
     }
     data.Read(_blockData, 0, _dataCount);
     data.Rewind();
     return true;
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:21,代码来源:SorensonVideo.cs

示例9: DecodeClientBW

		static ClientBW DecodeClientBW(ByteBuffer stream) 
		{
			return new ClientBW(stream.GetInt(), stream.Get());
		}
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:4,代码来源:RtmpProtocolDecoder.cs

示例10: AddData

		public bool AddData(ByteBuffer data) {
			if (data.Limit == 0)
				return false;// Empty buffer
			if (!CanHandleData(data))
				return false;
			data.Get();
			UpdateSize(data);
			int idx = 0;
			int pos = 0;
			byte[] tmpData = new byte[_blockDataSize];

			int countBlocks = _blockCount;
			while (data.Remaining > 0 && countBlocks > 0) {
				short size = data.GetShort();
				countBlocks--;
				if (size == 0) {
					// Block has not been modified
					idx += 1;
					pos += _blockDataSize;
					continue;
				}
				// Store new block data
				_blockSize[idx] = size;
				data.Read(tmpData, 0, size);
				Array.Copy(tmpData, 0, _blockData, pos, size);
				idx += 1;
				pos += _blockDataSize;
			}
			data.Rewind();
			return true;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:31,代码来源:ScreenVideo.cs

示例11: Encode

		// end input remaining
		/// <summary>
		/// Performs Base64 encoding on the <code>raw</code> ByteBuffer,
		/// writing it to the <code>encoded</code> CharBuffer.
		/// </summary>
		/// <remarks>
		/// Performs Base64 encoding on the <code>raw</code> ByteBuffer,
		/// writing it to the <code>encoded</code> CharBuffer.
		/// This is an experimental feature. Currently it does not
		/// pass along any options (such as
		/// <see cref="DoBreakLines">DoBreakLines</see>
		/// or
		/// <see cref="Gzip">Gzip</see>
		/// .
		/// </remarks>
		/// <param name="raw">input buffer</param>
		/// <param name="encoded">output buffer</param>
		/// <since>2.3</since>
		public static void Encode(ByteBuffer raw, CharBuffer encoded)
		{
			byte[] raw3 = new byte[3];
			byte[] enc4 = new byte[4];
			while (raw.HasRemaining())
			{
				int rem = Math.Min(3, raw.Remaining());
				raw.Get(raw3, 0, rem);
				Couchbase.Lite.Support.Base64.Encode3to4(enc4, raw3, rem, Couchbase.Lite.Support.Base64
					.NoOptions);
				for (int i = 0; i < 4; i++)
				{
					encoded.Put((char)(enc4[i] & unchecked((int)(0xFF))));
				}
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:34,代码来源:Base64.cs

示例12: ProcessExtendedHeader

		//Process the Extended Header in the ID3v2 Tag, returns the number of bytes to skip
		private int ProcessExtendedHeader(ByteBuffer data, byte version)
		{
			//TODO Verify that we have an syncsfe int
			int extsize = 0;
			byte[] exthead = new byte [4];
			data.Get(exthead);
			if (version == Id3Tag.ID3V23)
				extsize = ReadInteger(data, Id3Tag.ID3V23);
			else
				extsize = Utils.ReadSyncsafeInteger(new byte[]{data.Get(), data.Get(), data.Get(), data.Get()});

			// The extended header size includes those first four bytes.
			data.Position = data.Position + extsize;
			return extsize;
		}
开发者ID:emtees,项目名称:old-code,代码行数:16,代码来源:Id3v24TagReader.cs

示例13: GLCompressedTexImage2D

 public void GLCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, ByteBuffer data)
 {
     int num;
     byte[] sourceArray = new byte[imageSize];
     byte[] destinationArray = new byte[(width * height) * 4];
     for (num = 0; num < imageSize; num++)
     {
         sourceArray[num] = (byte)data.Get();
     }
     if (internalformat == 0x8b96)
     {
         for (num = 0; num < (width * height); num++)
         {
             Array.Copy(sourceArray, sourceArray[0x400 + num] * 4, destinationArray, num * 4, 4);
         }
     }
     else
     {
         for (num = 0; num < (width * height); num++)
         {
             int index = sourceArray[0x200 + num] * 2;
             destinationArray[(num * 4) + 3] = (byte)(sourceArray[index] << 4);
             destinationArray[(num * 4) + 2] = (byte)(sourceArray[index] & 240);
             destinationArray[(num * 4) + 1] = (byte)(sourceArray[index + 1] << 4);
             destinationArray[num * 4] = (byte)(sourceArray[index + 1] & 240);
         }
     }
     this.sTextures[this.sTextureId] = new Texture2D(device, width, height);
     this.sTextures[this.sTextureId].SetData<byte>(destinationArray);
 }
开发者ID:ordanielcmessias,项目名称:LGame,代码行数:30,代码来源:GL.cs

示例14: Put

        /// <summary>
        /// Transfers the specified number of bytes from the given source buffer into this buffer.
        /// </summary>
        /// <param name="src">The source buffer from which bytes are to be read; must not be this buffer.</param>
        /// <param name="count">Number of bytes to transfer.</param>
		public void Put(ByteBuffer src, int count)
		{
			for(int i=0; i < count; i++)
			{
				Put(src.Get());
			}
		}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:12,代码来源:ByteBuffer.cs

示例15: DoSend

    private static void DoSend()
    {
        while (true)
        {
            if (CSMsgQueue.Count <= 0)
            {
                Thread.Sleep(1000);
                continue;
            }

            Stream postStream = null;
            HttpWebResponse hwresponse = null;
            Stream responseStream = null;
            try
            {
                TBase csMsg;
                lock (CSMsgQueue.SyncRoot)
                {
                    csMsg = CSMsgQueue.Dequeue() as TBase;
                }
                if (csMsg == null)
                {
                    continue;
                }

                Logger.Log("Do send" + csMsg.GetType());

                var hwrequest = (HttpWebRequest)WebRequest.Create(ServiceManager.ServerData.Url);
                hwrequest.Accept = "*/*";
                hwrequest.AllowAutoRedirect = true;
                hwrequest.UserAgent = "http_requester/0.1";
                hwrequest.Timeout = 60000;
                hwrequest.Method = Method;
                hwrequest.Headers.Add("ISESSION", sessionId);
                hwrequest.ContentType = "multipart/form-data";

                var msg = new ThriftCSMessage(csMsg);
                var postByteArray = msg.Encode();
                if (postByteArray == null || postByteArray.Length <= 0)
                {
                    // Logger.LogError("send data is null or length is 0, msg type = " + csMsg.GetType().ToString());
                    continue;
                }

                hwrequest.ContentLength = postByteArray.Length;

                postStream = hwrequest.GetRequestStream();
                postStream.Write(postByteArray, 0, postByteArray.Length);
                postStream.Close();
                postStream = null;

                // deal with receive sc msg
                hwresponse = (HttpWebResponse)hwrequest.GetResponse();
                Logger.Log("response status:" + hwresponse.StatusCode);
                //Throw the message receive event.
                if (OnMessageReceived != null)
                {
                    OnMessageReceived();
                }
                if (hwresponse.StatusCode == HttpStatusCode.OK)
                {

                    var respLen = (int)hwresponse.ContentLength;
                    Logger.Log("respLen:" + respLen);
                    if (respLen <= 0)
                    {
                        hwresponse.Close();
                        hwresponse = null;
                        continue;
                    }

                    responseStream = hwresponse.GetResponseStream();
                    ByteBuffer recBuffer = new ByteBuffer(respLen);
                    var recDataPerTime = new byte[PkgReadLenPerTime];
                    long totalBytesRead = 0;
                    int bytesRead;

                    while ((bytesRead = responseStream.Read(recDataPerTime, 0, recDataPerTime.Length)) > 0)
                    {
                        totalBytesRead += bytesRead;
                        recBuffer.Put(recDataPerTime, bytesRead);
                    }
                    if (totalBytesRead < respLen)
                    {
                        Logger.Log("An error occurred: msg read len is not:" + respLen);
                        continue;
                    }
                    recBuffer.Flip();

                    var recDatas = new byte[respLen];
                    recBuffer.Get(recDatas);
                    responseStream.Close();
                    responseStream = null;

                    SocketClient.DecodeMsg(recDatas, respLen, SCMsgQueue);

                    sessionId = hwresponse.GetResponseHeader("ISESSION");
                }

                hwresponse.Close();
//.........这里部分代码省略.........
开发者ID:wuxin0602,项目名称:Nothing,代码行数:101,代码来源:NetManager.cs


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