Example #1
0
 public override void FlushToDisk(Stream stream, List <T> items)
 {
     using (var outstream = new StreamWriter(stream)) {
         var writer     = new JsonTextWriter(outstream);
         var serializer = JsonSerializer.CreateDefault();
         // Invoke custom serialization in BiggyListSerializer
         var biggySerializer = new BiggyListSerializer();
         biggySerializer.WriteJson(writer, items, serializer);
     }
 }
Example #2
0
        public bool FlushToDisk()
        {
            var completed = false;

            // Serialize json directly to the output stream
            using (var outstream = new StreamWriter(this.DbPath)) {
                var writer     = new JsonTextWriter(outstream);
                var serializer = JsonSerializer.CreateDefault();
                // Invoke custom serialization in BiggyListSerializer
                var biggySerializer = new BiggyListSerializer();
                biggySerializer.WriteJson(writer, _items, serializer);
                completed = true;
            }
            return(completed);
        }
Example #3
0
        public async Task <bool> FlushToDiskAsync()
        {
            await CreateOrOpenFolder();

            var completed = false;

            // Serialize json directly to the output stream
            using (Stream stream = await _dataFolder.OpenStreamForWriteAsync(_dbFileName, CreationCollisionOption.ReplaceExisting))
                using (var outstream = new StreamWriter(stream))
                {
                    var writer     = new JsonTextWriter(outstream);
                    var serializer = JsonSerializer.CreateDefault();
                    // Invoke custom serialization in BiggyListSerializer
                    var biggySerializer = new BiggyListSerializer();
                    biggySerializer.WriteJson(writer, _items, serializer);
                    completed = true;
                }
            return(completed);
        }