Esempio n. 1
0
        /// <summary>
        /// Loads a data stream as a <see cref="FrontendPackage"/>.
        /// </summary>
        /// <param name="br">The <see cref="BinaryReader"/> for the data stream.</param>
        /// <returns>A new <see cref="FrontendPackage"/> instance.</returns>
        public FrontendPackage Load(BinaryReader br)
        {
            FrontendPackage     package     = new FrontendPackage();
            FrontendChunkReader chunkReader = new FrontendChunkReader(package, br);

            foreach (var chunk in chunkReader.ReadMainChunks())
            {
                switch (chunk)
                {
                case PackageHeaderChunk packageHeaderChunk:
                    this.ProcessPackageHeaderChunk(package, packageHeaderChunk);
                    break;

                case ObjectContainerChunk objectContainerChunk:
                    ProcessObjectContainerChunk(package, objectContainerChunk);
                    break;
                }
            }

            return(package);
        }
Esempio n. 2
0
 public FrontendChunkReader(FrontendPackage package, BinaryReader reader)
 {
     Package = package;
     Reader  = reader;
 }
Esempio n. 3
0
 public abstract void Read(FrontendPackage package, FrontendChunkBlock chunkBlock,
                           FrontendChunkReader chunkReader, BinaryReader reader);
Esempio n. 4
0
 public abstract FrontendObject Read(FrontendPackage package, ObjectReaderState readerState, BinaryReader reader);
Esempio n. 5
0
 public abstract void Read(BinaryReader br, FrontendChunkBlock chunkBlock, FrontendPackage package,
                           ushort id,
                           ushort length);
Esempio n. 6
0
 private void ProcessPackageHeaderChunk(FrontendPackage package, PackageHeaderChunk packageHeaderChunk)
 {
     package.Filename = packageHeaderChunk.Filename;
     package.Name     = packageHeaderChunk.Name;
 }
Esempio n. 7
0
 private void ProcessObjectContainerChunk(FrontendPackage package, ObjectContainerChunk objectContainerChunk)
 {
     package.Objects.AddRange(objectContainerChunk.Objects);
 }
Esempio n. 8
0
 public FrontendMessagesTagStream(BinaryReader reader, FrontendPackage package, FrontendChunkBlock frontendChunkBlock, long length) :
     base(reader, frontendChunkBlock, length)
 {
     Package = package;
 }