refactor: Load IDataStreamFactory(s) with dependency injection
So we can create ViewStreams that depend on other services, config, etc. Previously, the PrimitiveManager relied purely on static construction of types through reflection.
This commit is contained in:
1 parent
ae050d9401
commit
253512cef8
55 files changed
+2331
-155
No files matched your search
@@ -22,8 +22,7 @@ using Bts.DataStreamExpressions;
|
||||
// using BCG.Evaluator.DataStreamExpression;
|
||||
// using BCG.Utilities.Win32;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
|
||||
namespace BCG
|
||||
{
|
||||
@@ -49,9 +48,16 @@ namespace BCG
|
||||
private ViewStream? myAllTagsStream;
|
||||
private string myKQ;
|
||||
private TextWriter? myConsoleOutput;
|
||||
readonly PrimitiveManager primitiveManager;
|
||||
readonly IDataStreamFactory streamFactory;
|
||||
|
||||
public MainForm()
|
||||
public MainForm(PrimitiveManager primitiveManager)
|
||||
: this(primitiveManager, primitiveManager) { }
|
||||
|
||||
public MainForm(PrimitiveManager primitiveManager, IDataStreamFactory streamFactory)
|
||||
{
|
||||
this.primitiveManager = primitiveManager;
|
||||
this.streamFactory = streamFactory;
|
||||
//Task.Run(async () => await _run());
|
||||
InitializeComponent();
|
||||
// myKQ = ConfigurationRequester.getApplicationQualifier();
|
||||
@@ -109,11 +115,11 @@ namespace BCG
|
||||
private IDictionary myGetLibraryData()
|
||||
{
|
||||
SortedList retVal = new SortedList();
|
||||
string[] primitiveNames = PrimitiveManager.instance.getPrimitiveNames();
|
||||
string[] primitiveNames = primitiveManager.getPrimitiveNames();
|
||||
foreach (string pName in primitiveNames)
|
||||
{
|
||||
string aName = PrimitiveManager.instance.getAssemblyName(pName);
|
||||
ICollection cNames = PrimitiveManager.instance.getConstructorSigns(pName);
|
||||
string aName = primitiveManager.getAssemblyName(pName);
|
||||
ICollection cNames = primitiveManager.getConstructorSigns(pName);
|
||||
if (!retVal.Contains(aName))
|
||||
retVal.Add(aName, new SortedList());
|
||||
(retVal[aName] as IDictionary)[pName] = new ArrayList(cNames);
|
||||
@@ -194,7 +200,7 @@ namespace BCG
|
||||
myExp = exp;
|
||||
myCrono.Restart();
|
||||
|
||||
(myCurrentStream = myExp.getView(new Dictionary<string, StatementExpression>(0))).onChange += myCallback;
|
||||
(myCurrentStream = myExp.getView(new Dictionary<string, StatementExpression>(0), streamFactory)).onChange += myCallback;
|
||||
myChangeStyle = true;
|
||||
//new SimpleBindableStream(myExp.getView(new Hashtable())).onChange += new DataStream.ChangeDelegate(myCallback);
|
||||
/*
|
||||
@@ -432,7 +438,7 @@ namespace BCG
|
||||
private void MainForm_Closed(object sender, System.EventArgs e)
|
||||
{
|
||||
if (myExp != null)
|
||||
myExp.getView(new Dictionary<string, StatementExpression>(0)).onChange -= myCallback;
|
||||
myExp.getView(new Dictionary<string, StatementExpression>(0), primitiveManager).onChange -= myCallback;
|
||||
}
|
||||
|
||||
private void myMenuItemExecuteQueryClick(object sender, System.EventArgs e)
|
||||
@@ -667,7 +673,7 @@ namespace BCG
|
||||
DialogResult dr = ofd.ShowDialog(this);
|
||||
if (ofd.CheckFileExists && ofd.CheckPathExists && dr == DialogResult.OK)
|
||||
{
|
||||
PrimitiveManager.instance.loadAssembly(ofd.FileName);
|
||||
primitiveManager.loadAssembly(ofd.FileName);
|
||||
myLoadAssemblies();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using BCG;
|
||||
using bts;
|
||||
using bts.api.core;
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
using Bts.DataStreamQueryAnalyzer;
|
||||
using Bts.PubSub;
|
||||
|
||||
@@ -27,7 +28,14 @@ static class Program {
|
||||
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
|
||||
await Configuration.InitializeAsync(cfg.Sparkd);
|
||||
Log.Gen.info("Starting DataStreamQueryAnalyzer");
|
||||
var mainForm = new MainForm();
|
||||
var primitiveManager = new PrimitiveManager(
|
||||
new PrimitiveManagerConfig() {
|
||||
Assemblies = new() {
|
||||
"DataStream.dll",
|
||||
"SharedStreams.dll"
|
||||
},
|
||||
});
|
||||
var mainForm = new MainForm(primitiveManager);
|
||||
if (cfg.StreamFile is not null) {
|
||||
mainForm.loadFile(cfg.StreamFile);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user