示例#1
0
        public CapturedRxnTapeSource(TimeSpan duration, IFileMeta file, IStringCodec codec)
        {
            _codec      = codec;
            _skipErrors = codec.SkipErrors;

            File     = file;
            Duration = duration;
        }
示例#2
0
        public ITapeStuff GetOrCreate(string fulleName, IStringCodec codec = null)
        {
            var fileToGet = Path.Combine(_cfg.AppRoot, fulleName);
            var directory = _fileSystem.GetDirectoryPart(fileToGet);

            if (!directory.IsNullOrWhitespace() && !_fileSystem.ExistsDirectory(directory))
            {
                _fileSystem.CreateDirectory(directory);
            }

            return(RxnTape.FromSource(fileToGet, new CapturedRxnTapeSource(TimeSpan.Zero, _fileSystem.GetOrCreateFile(fileToGet), codec ?? _defaultCodec, _isStarted)));
        }
示例#3
0
        public CapturedEventRecorder(Stream recordTo, IStringCodec codec, Action <CapturedEventRecorder> onStop = null, TimeSpan?offSet = null, Func <DateTime> currentTime = null)
        {
            _codec  = codec;
            _onStop = onStop;
            _now    = currentTime ?? SystemClock.Now;
            _writer = new StreamWriter(recordTo, Encoding.UTF8, 4069, false);

            //special chars are written to the end of a file, im having no luck appending too it
            //using seeking, beause i dont know where the special chars are. using file.Append works
            //var crString = Environment.NewLine;
            //var crBytes = Encoding.UTF8.GetBytes(crString);
            //recordTo.Seek(crBytes.Length, SeekOrigin.End);
            _startedAt = offSet != null?_now().Add(offSet.Value) : _now();

            Duration = TimeSpan.Zero;
        }
示例#4
0
        public IEnumerable <ITapeStuff> GetAll(string directory = @".\", string mask = "*.*", IStringCodec codec = null)
        {
            var rootedDir = Path.Combine(_cfg.AppRoot, directory);

            if (!directory.IsNullOrWhitespace() && !_fileSystem.ExistsDirectory(rootedDir))
            {
                _fileSystem.CreateDirectory(rootedDir);
            }

            return(_fileSystem.GetFiles(rootedDir, mask, true)
                   .Select(f => RxnTape.FromSource(_fileSystem.PathCombine(rootedDir, f.Name), new CapturedRxnTapeSource(TimeSpan.Zero, _fileSystem.GetOrCreateFile(f.Fullname), codec ?? _defaultCodec))));
        }
示例#5
0
 public bfgFileSystemTapeRepository(IFileSystemService fileSystem, IAppStatusCfg cfg, IStringCodec codec)
 {
     _defaultCodec = codec;
     _fileSystem   = fileSystem;
     _cfg          = cfg;
 }