Exemple #1
0
        public override IEnumerable <ITextualStreamingRecord> ReadRecords()
        {
            string line;
            ITextualStreamingRecord record;

            while (true)
            {
                line = this.BaseTextReader.ReadLine();

                if (SolderFascadeAccessor.DataTypeFascade.IsNullOrEmpty(line))
                {
                    yield break;
                }

                // TODO fix counts
                record = new TextualStreamingRecord(this.ParserState.lineIndex, this.ParserState.lineIndex, this.ParserState.characterIndex);
                record.Add(string.Empty, line);

                yield return(record);
            }
        }
Exemple #2
0
        public override IAsyncEnumerable <ITextualStreamingRecord> ReadRecordsAsync(CancellationToken cancellationToken)
        {
            return(AsyncEnumerable.CreateEnumerable <ITextualStreamingRecord>(() => AsyncEnumerable.CreateEnumerator(MoveNextAsync, Current, Dispose)));

            async Task <bool> MoveNextAsync(CancellationToken cancellationToken_)
            {
                bool   hasNext;
                string line;
                ITextualStreamingRecord record;

                line = await this.BaseTextReader.ReadLineAsync();

                if (SolderFascadeAccessor.DataTypeFascade.IsNullOrEmpty(line))
                {
                    record  = null;
                    hasNext = false;
                }
                else
                {
                    // TODO fix counts
                    record = new TextualStreamingRecord(this.ParserState.lineIndex, this.ParserState.lineIndex, this.ParserState.characterIndex);
                    record.Add(string.Empty, line);
                    hasNext = true;
                }

                this.ParserState.record = record;
                return(hasNext);
            }

            ITextualStreamingRecord Current()
            {
                return(this.parserState.record);
            }

            void Dispose()
            {
                // do nothing
            }
        }