/
krasninja
/
querycat
Обзор
Документация
Войти
/
krasninja
/
querycat
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/QueryCat.Backend/Relational/Iterators/ActionRowsIterator.cs
60 строк
2 KB
Ivan Kozhin
"Rebalance" utils (again), improve AOT support
22 дек 2023, 08:49
22 дек 2023, 08:49
b81d64f
Код
Авторство
О чём код?
using QueryCat.Backend.Core.Data; namespace QueryCat.Backend.Relational.Iterators; /// <summary> /// The iterator executes custom action before and/or after the next row fetch. /// </summary> internal sealed class ActionRowsIterator : IRowsIterator, IRowsIteratorParent { public string Message { get; set; } private readonly IRowsIterator _rowsIterator; public Action<IRowsIterator>? BeforeMoveNext { get; set; } public Action<IRowsIterator>? AfterMoveNext { get; set; } /// <inheritdoc /> public Column[] Columns => _rowsIterator.Columns; /// <inheritdoc /> public Row Current => _rowsIterator.Current; public ActionRowsIterator(IRowsIterator rowsIterator, string message) { Message = message; _rowsIterator = rowsIterator; } /// <inheritdoc /> public bool MoveNext() { BeforeMoveNext?.Invoke(_rowsIterator); var result = _rowsIterator.MoveNext(); if (result) { AfterMoveNext?.Invoke(_rowsIterator); } return result; } /// <inheritdoc /> public void Reset() { _rowsIterator.Reset(); } /// <inheritdoc /> public void Explain(IndentedStringBuilder stringBuilder) { stringBuilder.AppendRowsIteratorsWithIndent( $"Action (msg='{Message}' before={BeforeMoveNext != null} after={AfterMoveNext != null})", _rowsIterator); } /// <inheritdoc /> public IEnumerable<IRowsSchema> GetChildren() { yield return _rowsIterator; } }