private string[] GetContainerNames()
        {
            var output = DockerCli.Execute("ps --format \"{{.Names}}\"");

            return(output
                   .Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)
                   .OrderBy(n => n)
                   .ToArray());
        }
        private string[] GetProcessIdsFromContainer(string containerName)
        {
            var dotnetPids = DockerCli.Execute($"exec -it {containerName} pidof dotnet");

            return(dotnetPids
                   .Split(new[] { "\r\n", "\r", "\n", " " }, StringSplitOptions.RemoveEmptyEntries)
                   .OrderBy(n => n)
                   .ToArray());
        }
        private void UpdateDotNetPIDs()
        {
            AttachButton.IsEnabled = false;
            PidComboBox.IsEnabled  = false;

            var containerName = ContainerComboBox.SelectedItem as string;

            if (string.IsNullOrWhiteSpace(containerName))
            {
                return;
            }

            var pidofResult = DockerCli.Execute($"exec -it {containerName} pidof dotnet");

            var dotnetPidsParsed = pidofResult
                                   .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                   .Select(pidStr => (valid: int.TryParse(pidStr.Trim(), out int pid), pid))
                                   .ToArray();

            if (dotnetPidsParsed.Length == 0 || dotnetPidsParsed.Any(vp => !vp.valid))
            {
                PidComboBox.ItemsSource   = new[] { "Cannot find dotnet process!" };
                PidComboBox.SelectedIndex = 0;
            }
            else
            {
                var dotnetPids = dotnetPidsParsed.Select(vp => vp.pid).ToArray();

                PidComboBox.ItemsSource   = dotnetPids;
                PidComboBox.SelectedIndex = 0;

                if (dotnetPids.Length > 1)
                {
                    PidComboBox.IsEnabled = true;
                }

                if (dotnetPids.Length > 0)
                {
                    AttachButton.IsEnabled = true;
                }
            }
        }