62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using BCG;
|
|
|
|
using Bts.DataStream.Services;
|
|
using Bts.DataStreamCore.Services;
|
|
using Bts.Extensions.Hosting;
|
|
using Bts.PubSub.Services;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Spark.Api.MarketData;
|
|
using Spark.Api.Services;
|
|
using Spark.Core.Services;
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
static class Program {
|
|
static async Task<int> Main(string[] args) {
|
|
Console.Write("Starting DataStreamQueryAnalyzer");
|
|
int exitCode = 0;
|
|
IHost? host = null;
|
|
try {
|
|
host = HostBuilderExtensions.CreateBtsBuilder(args)
|
|
.ConfigureServices(ConfigureServices)
|
|
.Build();
|
|
var mdClient = host.Services.GetService<IMarketDataClient>();
|
|
if (mdClient is not null) {
|
|
PrimitiveManager.SetMarketDataClient(mdClient);
|
|
}
|
|
await host.StartAsync();
|
|
var winFormsThread = new Thread(RunWinFormsApp);
|
|
winFormsThread.SetApartmentState(ApartmentState.STA);
|
|
winFormsThread.Start();
|
|
winFormsThread.Join();
|
|
} catch (Exception ex) {
|
|
Console.Error.Write($"DataStreamQueryAnalyzer crashed: {ex}");
|
|
exitCode = 1;
|
|
}
|
|
if (host is not null) {
|
|
await host.StopAsync();
|
|
}
|
|
return exitCode;
|
|
}
|
|
|
|
static void RunWinFormsApp() {
|
|
var win = new MainForm();
|
|
Application.Run(win);
|
|
}
|
|
|
|
static void ConfigureServices(HostBuilderContext context, IServiceCollection services) =>
|
|
services.AddSpark(context.Configuration.GetSection("Spark"))
|
|
.AddSparkApi(context.Configuration.GetSection("SparkApi"))
|
|
.AddMasterWorker(context.Configuration.GetSection("MasterWorker"))
|
|
.AddViewStreamDatabase()
|
|
.AddPubSubClient(context.Configuration.GetSection("PubSub"))
|
|
.AddPubTableBroker()
|
|
.AddRemoteQueryManager();
|
|
}
|