コード例 #1
0
        internal static PsnDataPacketChunk Deserialize(PsnChunkHeader chunkHeader, PsnBinaryReader reader)
        {
            var subChunks = new List <PsnChunk>();

            foreach (var pair in FindSubChunkHeaders(reader, chunkHeader.DataLength))
            {
                reader.Seek(pair.Item2, SeekOrigin.Begin);

                switch ((PsnDataPacketChunkId)pair.Item1.ChunkId)
                {
                case PsnDataPacketChunkId.PsnDataHeader:
                    subChunks.Add(PsnDataHeaderChunk.Deserialize(pair.Item1, reader));
                    break;

                case PsnDataPacketChunkId.PsnDataTrackerList:
                    subChunks.Add(PsnDataTrackerListChunk.Deserialize(pair.Item1, reader));
                    break;

                default:
                    subChunks.Add(PsnUnknownChunk.Deserialize(pair.Item1, reader));
                    break;
                }
            }

            return(new PsnDataPacketChunk(subChunks));
        }
コード例 #2
0
        /// <summary>
        ///     Searches the binary stream for the positions of sub-chunk headers
        /// </summary>
        /// <exception cref="IOException">An I/O error occurs. </exception>
        /// <exception cref="NotSupportedException">The stream does not support seeking. </exception>
        internal static IEnumerable <Tuple <PsnChunkHeader, long> > FindSubChunkHeaders(PsnBinaryReader reader,
                                                                                        int chunkDataLength)
        {
            var  chunkHeaders = new List <Tuple <PsnChunkHeader, long> >();
            long startPos     = reader.BaseStream.Position;

            while (reader.BaseStream.Position - startPos < chunkDataLength)
            {
                var chunkHeader = reader.ReadChunkHeader();
                chunkHeaders.Add(Tuple.Create(chunkHeader, reader.BaseStream.Position));
                reader.Seek(chunkHeader.DataLength, SeekOrigin.Current);

                Debug.Assert(reader.BaseStream.Position - startPos <= chunkDataLength);
            }

            reader.Seek(startPos, SeekOrigin.Begin);

            return(chunkHeaders);
        }
コード例 #3
0
        internal static PsnDataTrackerListChunk Deserialize(PsnChunkHeader chunkHeader, PsnBinaryReader reader)
        {
            var subChunks = new List <PsnDataTrackerChunk>();

            foreach (var pair in FindSubChunkHeaders(reader, chunkHeader.DataLength))
            {
                reader.Seek(pair.Item2, SeekOrigin.Begin);
                subChunks.Add(PsnDataTrackerChunk.Deserialize(pair.Item1, reader));
            }

            return(new PsnDataTrackerListChunk(subChunks));
        }
コード例 #4
0
        internal static PsnDataTrackerChunk Deserialize(PsnChunkHeader chunkHeader, PsnBinaryReader reader)
        {
            var subChunks = new List <PsnChunk>();

            foreach (var pair in FindSubChunkHeaders(reader, chunkHeader.DataLength))
            {
                reader.Seek(pair.Item2, SeekOrigin.Begin);

                switch ((PsnDataTrackerChunkId)pair.Item1.ChunkId)
                {
                case PsnDataTrackerChunkId.PsnDataTrackerPos:
                    subChunks.Add(PsnDataTrackerPosChunk.Deserialize(chunkHeader, reader));
                    break;

                case PsnDataTrackerChunkId.PsnDataTrackerSpeed:
                    subChunks.Add(PsnDataTrackerSpeedChunk.Deserialize(chunkHeader, reader));
                    break;

                case PsnDataTrackerChunkId.PsnDataTrackerOri:
                    subChunks.Add(PsnDataTrackerOriChunk.Deserialize(chunkHeader, reader));
                    break;

                case PsnDataTrackerChunkId.PsnDataTrackerStatus:
                    subChunks.Add(PsnDataTrackerStatusChunk.Deserialize(chunkHeader, reader));
                    break;

                case PsnDataTrackerChunkId.PsnDataTrackerAccel:
                    subChunks.Add(PsnDataTrackerAccelChunk.Deserialize(chunkHeader, reader));
                    break;

                case PsnDataTrackerChunkId.PsnDataTrackerTrgtPos:
                    subChunks.Add(PsnDataTrackerTrgtPosChunk.Deserialize(chunkHeader, reader));
                    break;

                case PsnDataTrackerChunkId.PsnDataTrackerTimestamp:
                    subChunks.Add(PsnDataTrackerTimestampChunk.Deserialize(chunkHeader, reader));
                    break;

                default:
                    subChunks.Add(PsnUnknownChunk.Deserialize(chunkHeader, reader));
                    break;
                }
            }

            return(new PsnDataTrackerChunk(chunkHeader.ChunkId, subChunks));
        }