static CommandlineOptions ParseCommandlineArguments(string[] args) { CommandlineOptions result = new CommandlineOptions(); foreach (var arg in args.Select(a => a.ToLowerInvariant())) { if (arg.StartsWith("/parent:")) { var parts = arg.Split(':'); if (parts?.Length == 2 && int.TryParse(parts[1], out int pid)) { result.ParentProcessId = pid; } } else if (arg == "/debugform") { result.ShowDebugForm = true; } } return(result); }
public MonitorApplicationContext(CommandlineOptions commandline) { messageClient = new XDMessagingClient(); broadcaster = messageClient.Broadcasters.GetBroadcasterForMode(XDTransportMode.HighPerformanceUI); sink = messageClient.Listeners.GetListenerForMode(XDTransportMode.HighPerformanceUI); sink.RegisterChannel("ExplorerObserverCommand"); sink.MessageReceived += Sink_MessageReceived; observer = new ExplorerMonitor(); observer.ExplorerSelectionChanged += Observer_ExplorerSelectionChanged; observer.ExplorerWindowGotFocus += Observer_ExplorerWindowGotFocus; WatchParentProcessExit(commandline.ParentProcessId); observer.Start(); if (commandline.ShowDebugForm) { this.MainForm = new DebugForm(); this.MainForm.Show(); } }