Reduce overuse of null-conditional operator

This commit is contained in:
Martin Johns 2015-12-07 09:57:49 +01:00 committed by John Luo
parent 455d865948
commit 5e837b4eef
1 changed files with 10 additions and 6 deletions

View File

@ -88,14 +88,18 @@ namespace Microsoft.AspNet.Hosting
_configureServices(services);
}
if (PlatformServices.Default?.Application != null)
var defaultPlatformServices = PlatformServices.Default;
if (defaultPlatformServices != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Application));
}
if (defaultPlatformServices.Application != null)
{
services.TryAdd(ServiceDescriptor.Instance(defaultPlatformServices.Application));
}
if (PlatformServices.Default?.Runtime != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Runtime));
if (defaultPlatformServices.Runtime != null)
{
services.TryAdd(ServiceDescriptor.Instance(defaultPlatformServices.Runtime));
}
}
return services;