-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppEnvironment.cs
36 lines (29 loc) · 1.04 KB
/
AppEnvironment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
namespace NetPro.Checker
{
public class AppEnvironment
{
public int ProcessId { get; private set; }
public DateTime ProcessStartTime { get; private set; }
public string Hostname { get; private set; }
public Dictionary<string, string> EnvironmentVariables { get; } = new Dictionary<string, string>();
public static AppEnvironment GetAppEnvironment()
{
var env = new AppEnvironment
{
ProcessId = Process.GetCurrentProcess().Id,
ProcessStartTime = Process.GetCurrentProcess().StartTime.ToUniversalTime(),
Hostname = Dns.GetHostName()
};
var envVars = Environment.GetEnvironmentVariables();
foreach (var envVarKey in envVars.Keys)
{
env.EnvironmentVariables.Add(envVarKey.ToString(), envVars[envVarKey].ToString());
}
return env;
}
}
}