Make work on Xplat CoreCLR

This commit is contained in:
Brennan 2015-08-21 16:28:16 -07:00
parent 599f05e134
commit acefcff61d
2 changed files with 16 additions and 2 deletions

View File

@ -21,11 +21,25 @@ namespace MusicStore
private bool? _isNano; private bool? _isNano;
private bool? _isMono; private bool? _isMono;
private bool? _isWindows;
public Platform(IRuntimeEnvironment runtimeEnvironment) public Platform(IRuntimeEnvironment runtimeEnvironment)
{ {
_runtimeEnvironment = runtimeEnvironment; _runtimeEnvironment = runtimeEnvironment;
} }
public bool IsRunningOnWindows
{
get
{
if (_isWindows == null)
{
_isWindows = _runtimeEnvironment.OperatingSystem.Equals("Windows", StringComparison.OrdinalIgnoreCase);
}
return _isWindows.Value;
}
}
public bool IsRunningOnMono public bool IsRunningOnMono
{ {
@ -46,7 +60,7 @@ namespace MusicStore
{ {
if (_isNano == null) if (_isNano == null)
{ {
var osVersion = new Version(_runtimeEnvironment.OperatingSystemVersion); var osVersion = new Version(_runtimeEnvironment.OperatingSystemVersion ?? "");
try try
{ {

View File

@ -38,7 +38,7 @@ namespace MusicStore
{ {
services.Configure<AppSettings>(Configuration.GetSection("AppSettings")); services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
var useInMemoryStore = _platform.IsRunningOnMono || _platform.IsRunningOnNanoServer; var useInMemoryStore = !_platform.IsRunningOnWindows || _platform.IsRunningOnMono || _platform.IsRunningOnNanoServer;
// Add EF services to the services container // Add EF services to the services container
if (useInMemoryStore) if (useInMemoryStore)