40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
#nullable enable
|
|
namespace Bts.DataStreamCore;
|
|
|
|
using BCG;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public static class BlueTableSelectorWrapper {
|
|
public static BlueTableSelectorWrapper<T> Create<T>(
|
|
IBlueRowCollection source, Func<IBlueRow, T> selector, IBlueTableSchema? schema = null) where T : IBlueRow =>
|
|
new(source, selector, schema);
|
|
}
|
|
|
|
public class BlueTableSelectorWrapper<T> : IBlueRowCollection<T> where T : IBlueRow {
|
|
readonly IBlueRowCollection source;
|
|
readonly Func<IBlueRow, T> selector;
|
|
|
|
public BlueTableSelectorWrapper(IBlueRowCollection source, Func<IBlueRow, T> selector, IBlueTableSchema? schema = null) {
|
|
this.source = source;
|
|
this.selector = selector;
|
|
this.schema = schema ?? source.schema;
|
|
}
|
|
|
|
public T this[int id] => selector(source[id]);
|
|
|
|
public IBlueTableSchema schema { get; }
|
|
|
|
public int Count => source.Count;
|
|
|
|
public bool containsID(int id) =>
|
|
source.containsID(id);
|
|
|
|
public IEnumerator<T> GetEnumerator() {
|
|
foreach (IBlueRow r in source) {
|
|
yield return selector(r);
|
|
}
|
|
}
|
|
}
|