Files
spark/src/client/sparkcmd/ScriptClient.cs
T

41 lines
1.4 KiB
C#

using bts.api.core;
using bts.api.diagnostic;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace sparkcmd {
internal static class ScriptClient {
internal static void start(string qualifier, Stream stream) {
using (var ctx = new ServiceContext()) {
ShellDiagnosticService diag = ctx.locate<ShellDiagnosticService>(qualifier);
var script_id = diag.create(null);
ShellScriptHost script = ctx.locate<ShellScriptHost>(script_id.Id);
using (var reader = new StreamReader(stream)) {
var line = reader.ReadLine();
while(line != null) {
script.run(new ScriptLines {
Lines = { line }
});
line = reader.ReadLine();
}
}
}
}
public static void runserver() {
using (var ctx = new ServiceContext()) {
var assembly = Assembly.GetAssembly(typeof(mbts.ui.shell.App));
var stype = assembly.GetType("bts.api.diagnostic.ShellDiagnosticsServiceServer");
var server = Activator.CreateInstance(stype, ctx);
//ShellDiagnosticsServiceServer server = new bts.api.diagnostic.ShellDiagnosticsServiceServer(ctx);
while (true) System.Threading.Thread.Sleep(1000);
}
}
}
}