示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DatFile"/> class using specified resolver and activator.
        /// </summary>
        public DatFile(IChunkResolver <Magics> chunkResolver, IChunkActivator chunkActivator)
        {
            _chunkResolver  = chunkResolver ?? throw new ArgumentNullException(nameof(chunkResolver));
            _chunkActivator = chunkActivator ?? throw new ArgumentNullException(nameof(chunkActivator));
            _header         = new Header();

            HasGenericFlag = true;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of <see cref="ChunkReader{TMagic,TChunk}" />.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        /// <param name="chunkResolver">The resolver to use to find the type associated with the magic.</param>
        /// <param name="chunkActivator">The chunk activator used to create chunk instances.</param>
        /// <param name="leaveOpen">True to leave the stream open.</param>
        public ChunkReader(Stream stream, IChunkResolver chunkResolver, IChunkActivator chunkActivator, bool leaveOpen)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            _reader         = new BinaryReader(stream, Encoding.Default, leaveOpen);
            _chunkResolver  = chunkResolver ?? throw new ArgumentNullException(nameof(chunkResolver));
            _chunkActivator = chunkActivator ?? throw new ArgumentNullException(nameof(chunkActivator));
        }