Exemple #1
0
        private static Task <IAsyncRecord> ApplyRecordIndexAsync(long recordIndex, IAsyncRecord asyncRecord)
        {
            if ((object)asyncRecord == null)
            {
                throw new ArgumentNullException(nameof(asyncRecord));
            }

            asyncRecord.Index = recordIndex;

            return(Task.FromResult(asyncRecord));
        }
        protected override async Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken)
        {
            IAsyncEnumerable <IAsyncRecord> records;

            if ((object)asyncContext == null)
            {
                throw new ArgumentNullException(nameof(asyncContext));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)asyncChannel == null)
            {
                throw new ArgumentNullException(nameof(asyncChannel));
            }

            this.AssertValidConfiguration();

            records = asyncChannel.Records;

            if ((object)records == null)
            {
                throw new SyncPremException(nameof(records));
            }

            IAsyncEnumerator <IAsyncRecord> recordz;

            recordz = records.GetEnumerator();

            if ((object)recordz == null)
            {
                throw new InvalidOperationException(nameof(recordz));
            }

            while (await recordz.MoveNext(cancellationToken))
            {
                IAsyncRecord record = recordz.Current;
                TextWriter.WriteLine(record);
            }
        }