void ExitOptions(Options opts, ProviderHost host) { if (id != opts.id) { return; } host.Solution_Stop_Thread(opts); }
public void ParseForStart(ProviderHost host) { // 通过命令行启动策略 //cd "C:\Program Files\SmartQuant Ltd\OpenQuant 2014" //C: //start OpenQuant.exe --file="D:\Users\Kan\Documents\OpenQuant 2014\Solutions\SMACrossover\SMACrossover.sln" --id=100 --run var args = Environment.GetCommandLineArgs(); var text = Environment.CommandLine; Console.WriteLine($"命令行: {text}"); CommandLine.Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(opts => RunOptions(opts, host)) .WithNotParsed <Options>((errs) => HandleParseError(errs)); }
void RunOptions(Options opts, ProviderHost host) { // 记下ID,退出时使用 id = opts.id; if (string.IsNullOrEmpty(opts.file)) { return; } if (!(new FileInfo(opts.file).Exists)) { return; } host.Solution_Start_Thread(opts); }
public void ParseForStop(ProviderHost host) { #if NET48 //echo --id=100 --stop --exit | clip IDataObject ido = Clipboard.GetDataObject(); if (!ido.GetDataPresent(DataFormats.Text)) { return; } var text = ido.GetData(DataFormats.Text) as string; Console.WriteLine($"剪贴板: {text}"); CommandLine.Parser.Default.ParseArguments <Options>(text.Split(' ')) .WithParsed <Options>(opts => ExitOptions(opts, host)) .WithNotParsed <Options>((errs) => HandleParseError(errs)); #endif }