Exemplo n.º 1
0
        private static void ListEnvironmentVariables(int pid)
        {
            // get environment variables via existing wrapper in DiagnosticsClient
            var client       = new DiagnosticsClient(pid);
            var envVariables = client.GetProcessEnvironment();

            foreach (var variable in envVariables.Keys.OrderBy(k => k))
            {
                // NOTE: there is a value for the empty/"" key = "ExitCode=00000000"
                Console.WriteLine($"{variable,26} = {envVariables[variable]}");
            }
        }
Exemplo n.º 2
0
        public Task <ActionResult <Dictionary <string, string> > > GetProcessEnvironment(
            ProcessFilter processFilter)
        {
            return(InvokeForProcess <Dictionary <string, string> >(processInfo =>
            {
                var client = new DiagnosticsClient(processInfo.EndpointInfo.Endpoint);

                try
                {
                    return client.GetProcessEnvironment();
                }
                catch (ServerErrorException)
                {
                    throw new InvalidOperationException("Unable to get process environment.");
                }
            },
                                                                   processFilter));
        }
Exemplo n.º 3
0
        public Task <ActionResult <Dictionary <string, string> > > GetProcessEnvironment(
            ProcessFilter processFilter)
        {
            return(this.InvokeService <Dictionary <string, string> >(async() =>
            {
                IProcessInfo processInfo = await _diagnosticServices.GetProcessAsync(
                    processFilter,
                    HttpContext.RequestAborted);

                var client = new DiagnosticsClient(processInfo.EndpointInfo.Endpoint);

                try
                {
                    return client.GetProcessEnvironment();
                }
                catch (ServerErrorException)
                {
                    throw new InvalidOperationException("Unable to get process environment.");
                }
            }));
        }
Exemplo n.º 4
0
        public Task <ActionResult <Dictionary <string, string> > > GetProcessEnvironment(
            ProcessKey processKey)
        {
            return(InvokeForProcess <Dictionary <string, string> >(processInfo =>
            {
                var client = new DiagnosticsClient(processInfo.EndpointInfo.Endpoint);

                try
                {
                    Dictionary <string, string> environment = client.GetProcessEnvironment();

                    _logger.WrittenToHttpStream();

                    return environment;
                }
                catch (ServerErrorException)
                {
                    throw new InvalidOperationException("Unable to get process environment.");
                }
            },
                                                                   processKey));
        }