Exemplo n.º 1
0
 public ItemReader(Stream stream, Span <byte> buffer, ItemSerializer <T> serializer)
 {
     this.stream     = stream;
     this.buffer     = buffer;
     TotalBytesRead  = 0L;
     this.serializer = serializer;
     bufferOffset    = 0;
     dataLength      = 0;
 }
Exemplo n.º 2
0
        public RubikStore(string filename, ItemSerializer <T> serializer, Action <T> add)
        {
            this.serializer = serializer;
            var filepath = Path.Combine(Directory.GetCurrentDirectory(), filename);

            Directory.CreateDirectory(Path.GetDirectoryName(filepath));
            stream = new BufferedStream(new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, BufferSize, FileOptions.SequentialScan), BufferSize);
            TryLoad(add);
            new Thread(FlushLoop)
            {
                IsBackground = true
            }.Start();
        }