public OperatingSystemFacade() { Assembly = new AssemblyFacade(); Dialog = new DialogFacade(); Environment = new Environment(); File = new FileFacade(); MemoryMappedFiles = new MemoryMappedFileFactory(); ProcessLocator = new ProcessLocator(); ProcessStarter = new ProcessStarter(); Registry = new Registry(); }
public OperatingSystemFacade() { Assembly = new AssemblyFacade(); Dialog = new DialogFacade(); Directory = new DirectoryFacade(); Environment = new Environment(); File = new FileFacade(); MemoryMappedFiles = new MemoryMappedFileFactory(); ProcessLocator = new ProcessLocator(); ProcessStarter = new ProcessStarter(); Registry = new Registry(); }
public async Task <int> OnExecuteAsync(CommandLineApplication app, IConsole console) { System.Threading.CancellationToken cancellationToken = console.GetCtrlCToken(); EndPoint endPoint; if (ProcessId is int pid) { ProcessRegistration reg = await ProcessLocator.GetRegistrationAsync(pid); endPoint = new IPEndPoint(IPAddress.Loopback, reg.DiagnosticsPort); } else { if (string.IsNullOrEmpty(Target)) { console.Error.WriteLine("Missing required option: --server"); return(1); } if (!EndPointParser.TryParseEndpoint(Target, out endPoint)) { console.Error.WriteLine($"Invalid server value: {Target}"); return(1); } } if (Providers.Count == 0) { console.Error.WriteLine("No providers were listed"); return(1); } var client = new DiagnosticsClient(endPoint); console.WriteLine("Connecting to application..."); client.OnEventWritten += (evt) => { var formattedMessage = string.Format(evt.Message, evt.Payload.ToArray()); console.WriteLine($"{evt.ProviderName}/{evt.EventName}({evt.EventId}): {formattedMessage}"); }; await client.ConnectAsync(); await client.EnableEventsAsync(Providers.Select(p => new EnableEventsRequest(p, EventLevel.Verbose, EventKeywords.All))); console.WriteLine("Connected, press Ctrl-C to terminate..."); await cancellationToken.WaitForCancellationAsync(); return(0); }
public async Task <int> OnExecuteAsync(CommandLineApplication app, IConsole console) { var pids = await ProcessLocator.GetAllProcessIdsAsync(); foreach (var pid in pids) { var reg = await ProcessLocator.GetRegistrationAsync(pid); console.WriteLine($"* {pid} {reg.ImageName} {reg.CommandLine} (port: {reg.DiagnosticsPort}, v{reg.ProtocolVersion})"); } return(0); }
private async Task StartListeningAsync() { _listener.Start(); if (_listener.LocalEndpoint is IPEndPoint ipep && IPAddress.IsLoopback(ipep.Address)) { var p = Process.GetCurrentProcess(); _registration = await ProcessLocator.RegisterProcessAsync(new ProcessRegistration( p.Id, ipep.Port, p.MainModule.ModuleName, Environment.CommandLine, protocolVersion : 1)); Trace("Registered with Process List"); } _ = AcceptLoop(_listener, _shutdownCts.Token); }