Example #1
0
        public void Read(IReadManager readManager)
        {
            using (FileStream fileToBeCompressed = new FileStream(SourceFile, FileMode.Open, FileAccess.Read))
            {
                int    bytesRead;
                byte[] lastBuffer;

                while (fileToBeCompressed.Position < fileToBeCompressed.Length)
                {
                    if (fileToBeCompressed.Length - fileToBeCompressed.Position <= _blockSize)
                    {
                        bytesRead = (int)(fileToBeCompressed.Length - fileToBeCompressed.Position);
                    }
                    else
                    {
                        bytesRead = _blockSize;
                    }

                    lastBuffer = new byte[bytesRead];
                    fileToBeCompressed.Read(lastBuffer, 0, bytesRead);
                    readManager.SetBlock(lastBuffer);
                    Progress.Show(fileToBeCompressed.Position, fileToBeCompressed.Length);
                }
            }
        }
Example #2
0
        public void Read(IReadManager readManager)
        {
            using (FileStream compressedFile = new FileStream(SourceFile, FileMode.Open, FileAccess.Read))
            {
                while (compressedFile.Position < compressedFile.Length)
                {
                    byte[] lengthBuffer = new byte[8];
                    compressedFile.Read(lengthBuffer, 0, lengthBuffer.Length);
                    int    blockLength    = BitConverter.ToInt32(lengthBuffer, 4);
                    byte[] compressedData = new byte[blockLength];
                    lengthBuffer.CopyTo(compressedData, 0);

                    compressedFile.Read(compressedData, 8, blockLength - 8);
                    int    dataSize   = BitConverter.ToInt32(compressedData, blockLength - 4);
                    byte[] lastBuffer = new byte[dataSize];

                    readManager.SetBlock(lastBuffer, compressedData);
                    Progress.Show(compressedFile.Position, compressedFile.Length);
                }
            }
        }
Example #3
0
 public ProductsController(IManager <Product> productsManager, IManager <Category> categoriesManager, IReadManager <ProductView> productsViewManager)
 {
     _productsManager     = productsManager;
     _categoriesManager   = categoriesManager;
     _productsViewManager = productsViewManager;
 }