Exemplo n.º 1
0
        public static IEnumerable <Sample> ReadAllSources(IEnumerable <string> paths, LocalFileReaderPool readersPool, ILogger logger, IChanelFactory chanelFactory)
        {
            var result  = new List <Sample>();
            var report  = new ReportPrototype(DateTime.Now);
            var reports = new List <string>(paths.Count());
            var timer   = new Stopwatch();

            foreach (var file in paths)
            {
                var stats     = new StatsBuilder(file);
                var extension = new FileInfo(file).Extension.Trim('.');
                var protocol  = ExtractProtocol(file);
                var chanel    = chanelFactory.Create(protocol);
                using (var stream = chanel.Connect(file))
                {
                    var reader = readersPool.Borrow(extension);
                    timer.Start();
                    var samples = reader.Read(stream);
                    timer.Stop();
                    readersPool.Release(reader);
                    result.AddRange(samples);

                    stats.AddDuration(timer.Elapsed);
                    stats.AddCount((uint)samples.Count());

                    timer.Reset();
                }

                reports.Add(report.Clone(stats.Build()));
                logger.Log(report.Clone(stats.Build()));
            }

            return(result);
        }
Exemplo n.º 2
0
 protected virtual void DiscardReader(ISamplesReader reader)
 {
     _readersPool.Release(reader);
 }