예제 #1
0
        void ExitOptions(Options opts, ProviderHost host)
        {
            if (id != opts.id)
            {
                return;
            }

            host.Solution_Stop_Thread(opts);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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
        }