コード例 #1
0
        async Task ICommandLineHandler.HandleCommandLineArgs(string[] args, CommandLineEventArgs evtArgs)
        {
            args = await HandleBatchArg(args, evtArgs);

            args = RemoveNamedArgs(args).ToArray();
            OpenArgsAsLogSources(args);
        }
コード例 #2
0
        async private Task <string[]> HandleBatchArg(string[] args, CommandLineEventArgs evtArgs)
        {
            var argsCopy = (string[])args.Clone();

            var batchArgIdx = args.IndexOf(a => a.ToLower() == "/batch");

            if (batchArgIdx != null)
            {
                argsCopy[batchArgIdx.Value] = null;
                if (args.Length > batchArgIdx.Value + 1)
                {
                    argsCopy[batchArgIdx.Value + 1] = null;
                    var batchFile = BatchFile.TryLoad(args[batchArgIdx.Value + 1]);
                    if (batchFile != null)
                    {
                        evtArgs.ContinueExecution = batchFile.StartUI;
                        var tasks = new List <Task>();
                        foreach (var cmd in batchFile.EnumCommands())
                        {
                            var handler = commandHandlers.FirstOrDefault(h => h.SupportedCommands.Contains(cmd.Key));
                            if (handler != null)
                            {
                                tasks.Add(Task.Run(() => handler.Run(cmd.Value)));
                            }
                        }
                        await Task.WhenAll(tasks);
                    }
                }
            }

            return(argsCopy.Where(a => a != null).ToArray());
        }
コード例 #3
0
ファイル: AppInitializer.cs プロジェクト: pnelson786/logjoint
        public void WireUpCommandLineHandler(
            LogJoint.UI.Presenters.MainForm.IPresenter mainFormPresenter,
            AppLaunch.ICommandLineHandler handler)
        {
            mainFormPresenter.Loaded += async(s, e) =>
            {
                string[] args = Environment.GetCommandLineArgs();
                if (args.Length > 1)
                {
                    var evtArgs = new AppLaunch.CommandLineEventArgs()
                    {
                        ContinueExecution = true
                    };
                    await handler.HandleCommandLineArgs(args.Skip(1).ToArray(), evtArgs);

                    if (!evtArgs.ContinueExecution)
                    {
                        mainFormPresenter.Close();
                    }
                }
            };
        }