From 5e837b4eef82a26e74b9ad1d0edddacea560a9ab Mon Sep 17 00:00:00 2001 From: Martin Johns Date: Mon, 7 Dec 2015 09:57:49 +0100 Subject: [PATCH] Reduce overuse of null-conditional operator --- src/Microsoft.AspNet.Hosting/WebHostBuilder.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs index 5c96962fb2..4157a831d5 100644 --- a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs @@ -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;