コード例 #1
0
        public async Task ReadFile(string file, ITargetBlock <string> sync)
        {
            _logger.LogInformation($"Reading file {file}");
            using StreamReader stream = new StreamReader(file, Encoding.UTF8, true, 65536);

            _counters.Increment(Counter.FileRead);

            int lineCount = 0;

            while (true)
            {
                string?line = stream.ReadLine();
                if (line == null)
                {
                    break;
                }

                await sync.SendAsync(line);

                _counters.Increment(Counter.FileLine);
                lineCount++;
            }

            _logger.LogInformation($"Read file {file}, count= {lineCount:n0}");
        }
コード例 #2
0
        public NmeaRecord?Parse(string line)
        {
            line.VerifyNotEmpty(nameof(line));

            _counters.Increment(Counter.Parser);
            _counters.Set(Counter.ParserFragment, _parser.Fragments.Count);

            Interlocked.Increment(ref _multiCount);
            _counters.SetMulti(_multiCount);

            try
            {
                NmeaRecord nmeaRecord = line[0..2] switch