internal static void SubArrayDeSerialize <valueType>(BinaryDeSerializer deSerializer, ref SubArray <valueType> value) { valueType[] array = null; deSerializer.isReferenceArray = false; TypeDeSerializer <valueType[]> .DefaultDeSerializer(deSerializer, ref array); value.Set(array, 0, array.Length); }
///// <summary> ///// 当前读取数据位置 ///// </summary> ///// <param name="end"></param> ///// <returns></returns> //[MethodImpl(AutoCSer.MethodImpl.AggressiveInlining)] //public byte* GetRead(out byte* end) //{ // end = this.end; // return Read; //} /// <summary> /// 获取数据缓冲区 /// </summary> /// <param name="buffer"></param> /// <returns></returns> public bool GetBuffer(ref SubArray <byte> buffer) { if (Buffer == null) { return(false); fixed(byte *bufferFixed = Buffer) buffer.Set(Buffer, (int)(Read - bufferFixed), (int)(End - Read)); return(true); }
/// <summary> /// 获取子串 /// </summary> /// <param name="startIndex"></param> /// <param name="length"></param> /// <returns></returns> public SubArray <valueType> GetSub(int startIndex, int length) { FormatRange range = new FormatRange(Length, startIndex, length); if (range.GetCount != length) { throw new IndexOutOfRangeException("startIndex[" + startIndex.toString() + "] + length[" + length.toString() + "] > Length[" + Length.toString() + "]"); } SubArray <valueType> value = default(SubArray <valueType>); value.Set(Array, Start + startIndex, length); return(value); }
public void CallDeSerialize(ref SubArray <byte> value) { int length = *(int *)Read; if (length == 0) { value.Length = 0; Read += sizeof(int); } else { if (((length + (3 + sizeof(int))) & (int.MaxValue - 3)) <= (int)(End - Read)) { byte[] array = new byte[length]; Read = DeSerialize(Read + sizeof(int), array); value.Set(array, 0, length); } else { State = DeSerializeState.IndexOutOfRange; } } }
internal void DeSerializeTcpServer(ref SubArray <byte> data, byte *read, int size) { data.Set(Buffer, (int)(read - start) + bufferIndex, size); }