chore: Add IDataStreamFactory for FilterStream

This commit is contained in:
John Colvin committed 2025-11-15 12:46:25 -05:00
1 parent 5d039b54f5
commit 8908cc300a
1 file changed
+42
@@ -0,0 +1,42 @@
namespace Bts.SharedStreams.StreamFactories;
using BCG;
using Bts.DataStreamCore;
using Bts.DataStreamExpressions;
using System.Collections.Generic;
public class FilterStreamFactory : IRecursiveDataStreamFactory {
IDataStreamFactory? compositeFactory;
public ViewStream? Create(string streamId, IEnumerable<(string? Name, int? Index, object? Value)> args) {
if (SupportedStreams.Filter.IsMatch(streamId)) {
return createFilter(args);
}
return null;
}
public IEnumerable<IDataStreamMetadata> GetSupportedStreams() {
yield return SupportedStreams.Filter;
}
public void OnCompositeFactory(IDataStreamFactory compositeFactory) =>
this.compositeFactory = compositeFactory;
ViewStream? createFilter(IEnumerable<(string? Name, int? Index, object? Value)> args) {
if (compositeFactory is null || !args.TryGetSingle(out var arg)) {
return null;
}
if (arg.Value is FunctionDefinition fnDef) {
fnDef.ToPredicate(new Dictionary<string, object?>(0), new Dictionary<string, FunctionDefinition>(0), compositeFactory);
}
throw new NotImplementedException();
}
static class SupportedStreams {
public static readonly DataStreamMetadata Filter = new() {
Name = "filter"
};
}
}