chore: Add IDataStreamFactory for FilterStream
This commit is contained in:
1 parent
3638b26bdf
commit
3431700c38
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"
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user