Example #1
0
 public void Dispose()
 {
     if (_saveHitContext)
     {
         var fileStream = _filesStream.GetOrAdd(_hitsPath, CreateOutputFile);
         lock (fileStream)
         {
             _hitContext.Serialize(fileStream);
             fileStream.Flush();
         }
         HitContext.Current = null;
     }
 }
Example #2
0
 public void Dispose()
 {
     if (_saveHitContext)
     {
         Directory.CreateDirectory(_hitsPath);
         var filePath = Path.Combine(_hitsPath, $"{Guid.NewGuid()}.hits");
         using (var fileStream = File.Open(filePath, FileMode.CreateNew))
         {
             _hitContext.Serialize(fileStream);
             fileStream.Flush();
         }
         HitContext.Current = null;
     }
 }
Example #3
0
        private void SaveHitContext()
        {
            lock (_hitContext)
            {
                if (_hitContext.Hits.Count == 0)
                {
                    return;
                }

                Directory.CreateDirectory(_hitsPath);

                var fileName = Path.Combine(_hitsPath, $"{_hitContext.Id}.hits");

                using (var fileStream = File.Open(fileName, FileMode.Create))
                {
                    _hitContext.Serialize(fileStream);
                    fileStream.Flush();
                }
            }
        }