Skip to content

Commit c3ce872

Browse files
committed
Fixed the bracket style on EnvironmentInfoCollector
1 parent 299def5 commit c3ce872

File tree

1 file changed

+14
-33
lines changed

1 file changed

+14
-33
lines changed

Source/Extras/Services/EnvironmentInfoCollector.cs

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,15 @@ public EnvironmentInfo GetEnvironmentInfo() {
4343
}
4444

4545
try {
46-
if (IsUnix)
47-
{
48-
if (PerformanceCounterCategory.Exists("Mono Memory"))
49-
{
46+
if (IsUnix) {
47+
if (PerformanceCounterCategory.Exists("Mono Memory")) {
5048
var totalPhysicalMemory = new PerformanceCounter("Mono Memory", "Total Physical Memory");
51-
var availablePhysicalMemory = new PerformanceCounter("Mono Memory", "Available Physical Memory"); //mono 4.0+
5249
info.TotalPhysicalMemory = Convert.ToInt64(totalPhysicalMemory.RawValue);
50+
51+
var availablePhysicalMemory = new PerformanceCounter("Mono Memory", "Available Physical Memory"); //mono 4.0+
5352
info.AvailablePhysicalMemory = Convert.ToInt64(availablePhysicalMemory.RawValue);
5453
}
55-
}
56-
else
57-
{
54+
} else {
5855
if (computerInfo != null) {
5956
info.TotalPhysicalMemory = Convert.ToInt64(computerInfo.TotalPhysicalMemory);
6057
info.AvailablePhysicalMemory = Convert.ToInt64(computerInfo.AvailablePhysicalMemory);
@@ -98,27 +95,21 @@ public EnvironmentInfo GetEnvironmentInfo() {
9895
}
9996

10097
try {
101-
if (IsUnix)
102-
{
98+
if (IsUnix) {
10399
var currentProcess = Process.GetCurrentProcess();
104100
info.ProcessId = currentProcess.Id.ToString(NumberFormatInfo.InvariantInfo);
105-
}
106-
else
107-
{
101+
} else {
108102
info.ProcessId = KernelNativeMethods.GetCurrentProcessId().ToString(NumberFormatInfo.InvariantInfo);
109103
}
110104
} catch (Exception ex) {
111105
_log.FormattedInfo(typeof(EnvironmentInfoCollector), "Unable to get process id. Error message: {0}", ex.Message);
112106
}
113107

114108
try {
115-
if (IsUnix)
116-
{
109+
if (IsUnix) {
117110
var currentProcess = Process.GetCurrentProcess();
118111
info.ProcessName = currentProcess.ProcessName;
119-
}
120-
else
121-
{
112+
} else {
122113
info.ProcessName = GetProcessName();
123114
}
124115
} catch (Exception ex) {
@@ -127,13 +118,9 @@ public EnvironmentInfo GetEnvironmentInfo() {
127118

128119
try {
129120
if (IsUnix)
130-
{
131-
info.ThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(NumberFormatInfo.InvariantInfo);
132-
}
121+
info.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(NumberFormatInfo.InvariantInfo);
133122
else
134-
{
135123
info.ThreadId = KernelNativeMethods.GetCurrentThreadId().ToString(NumberFormatInfo.InvariantInfo);
136-
}
137124
} catch (Exception ex) {
138125
_log.FormattedInfo(typeof(EnvironmentInfoCollector), "Unable to get thread id. Error message: {0}", ex.Message);
139126
}
@@ -183,16 +170,10 @@ private static bool Is64BitOperatingSystem() {
183170
return ((methodExist && KernelNativeMethods.IsWow64Process(KernelNativeMethods.GetCurrentProcess(), out is64)) && is64);
184171
}
185172

186-
/// <summary>
187-
/// Determine current os platform.
188-
/// </summary>
189-
/// <exception cref="InvalidOperationException" accessor="get"></exception>
190-
private static bool IsUnix
191-
{
192-
get
193-
{
194-
int p = (int)Environment.OSVersion.Platform;
195-
return (p == 4) || (p == 6) || (p == 128);
173+
private static bool IsUnix {
174+
get {
175+
int platform = (int)Environment.OSVersion.Platform;
176+
return platform == 4 || platform == 6 || platform == 128;
196177
}
197178
}
198179
}

0 commit comments

Comments
 (0)