コード例 #1
0
ファイル: StatisticsMemoryMap.cs プロジェクト: cdy816/mars
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        public void Load(System.IO.Stream stream)
        {
            mHead.Clear();
            mData.Clear();
            mAvaiableDataLen = 48;
            if (stream.Length < TagTotalCount * 8)
            {
                return;
            }

            byte[] bvals = System.Buffers.ArrayPool <byte> .Shared.Rent(4);

            //var br = new System.IO.BinaryReader(stream);
            stream.Read(bvals, 0, 4);
            var datasize = BitConverter.ToInt32(bvals, 0);

            mHead.ReadFromStream(stream, datasize);
            stream.Read(bvals, 0, 4);
            datasize = BitConverter.ToInt32(bvals, 0);

            mData.ReadFromStream(stream, datasize);
            mAvaiableDataLen = datasize;

            System.Buffers.ArrayPool <byte> .Shared.Return(bvals);
        }
コード例 #2
0
ファイル: LocalFileSeriser.cs プロジェクト: cdy816/mars
        /// <summary>
        ///
        /// </summary>
        /// <param name="start"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        public override MarshalMemoryBlock Read(long start, int len)
        {
            MarshalMemoryBlock re = new MarshalMemoryBlock(len, len);

            mStream.Position = start;
            re.ReadFromStream(mStream, len);
            return(re);
        }