Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Made uname() lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed May 6, 2015
1 parent 94d1648 commit f37d04f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/dnx.host/RuntimeEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

using System;
using System.Reflection;
using System.Runtime.Versioning;

namespace Microsoft.Framework.Runtime
{
public class RuntimeEnvironment : IRuntimeEnvironment
{
private string _osVersion;

private string _osName;

private string _runtimeVersion;

public RuntimeEnvironment()
Expand All @@ -22,12 +23,21 @@ public RuntimeEnvironment()
RuntimeType = Type.GetType("Mono.Runtime") == null ? "CLR" : "Mono";
RuntimeArchitecture = Environment.Is64BitProcess ? "x64" : "x86";
#endif

string uname = NativeMethods.Uname();
OperatingSystem = string.IsNullOrEmpty(uname) ? "Windows" : uname;
}

public string OperatingSystem { get; private set; }
public string OperatingSystem
{
get
{
if (_osName == null)
{
string uname = NativeMethods.Uname();
_osName = string.IsNullOrEmpty(uname) ? "Windows" : uname;
}

return _osName;
}
}

public string OperatingSystemVersion
{
Expand Down

0 comments on commit f37d04f

Please sign in to comment.