Beispiel #1
0
        protected static Stream PrepareFileStreaming(FileStreamingMode fileStreamingMode, ref int blockSize, FileStream fileStream)
        {
            // TODO: fix memory buffering
            return(fileStream);

            switch (fileStreamingMode)
            {
            case FileStreamingMode.Buffered:
                return(fileStream);

            case FileStreamingMode.CopyToMemory:
            {
                blockSize = 0;
                var temp = new MemoryStream();
                fileStream.CopyTo(temp);
                fileStream.Dispose();
                temp.Position = 0;
                return(temp);
            }
            break;

            default:
                throw new ArgumentOutOfRangeException(nameof(fileStreamingMode));
            }
        }
        public BinaryValueReader(string filePath, FileStreamingMode fileStreamingMode, Endianness endianness, Encoding encoding, int bufferSize = DEFAULT_BLOCK_SIZE)
        {
            var fileStream = File.OpenRead(filePath);
            var stream     = PrepareFileStreaming(fileStreamingMode, ref bufferSize, fileStream);

            Initialize(stream, StreamOwnership.Transfer, filePath, endianness, encoding, bufferSize);
        }
 public BinaryObjectWriter(string filePath, FileStreamingMode fileStreamingMode, Endianness endianness, Encoding encoding, int bufferSize = DEFAULT_BLOCK_SIZE)
     : base(filePath, fileStreamingMode, endianness, encoding, bufferSize)
 {
     Initialize();
 }
Beispiel #4
0
        public BinaryValueWriter(string filePath, FileStreamingMode fileStreamingMode, Endianness endianness, Encoding encoding = null, int bufferSize = DEFAULT_BLOCK_SIZE)
        {
            var fileStream = File.Create(filePath);

            Initialize(fileStream, StreamOwnership.Transfer, filePath, endianness, encoding, bufferSize);
        }