32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
namespace bts.SilverPine {
|
|
using System;
|
|
using BCG;
|
|
using System.Collections.Generic;
|
|
using Bts.DataStreamExpressions;
|
|
|
|
// All this does is take in a dsl expression, parse it and fire the data that come out of running it.
|
|
// So for example, if an expresison is passed
|
|
[DataStreamUserRespresentation("dsl")]
|
|
public class DSLStream : ViewStream {
|
|
private readonly string _dsl;
|
|
public DSLStream(string dsl) {
|
|
Log.Gen.info($"DSLStream.cons dsl: {dsl}");
|
|
_dsl = dsl;
|
|
ViewStream rs = build_stream(dsl);
|
|
rs = rs ?? new LiteralStream("error", $"msg:invalid dsl \"{dsl}\"");
|
|
mySetRealSource(rs);
|
|
}
|
|
|
|
static ViewStream? build_stream(string stream_expression) {
|
|
try {
|
|
var exp = DataStreamExpressionsInterpreter.Evaluate(stream_expression);
|
|
var rv = exp.getView(new Dictionary<string, StatementExpression>(0));
|
|
return rv;
|
|
|
|
} catch (Exception ex) {
|
|
Log.Gen.error($"Could not build stream: {stream_expression} ex: {ex}");
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
} |