More granualr null checks for platform services

This commit is contained in:
David Fowler 2015-10-23 02:59:50 -07:00
parent 02de506c28
commit fa72b35883
1 changed files with 17 additions and 1 deletions

View File

@ -92,12 +92,28 @@ namespace Microsoft.AspNet.Hosting
_configureServices(services);
}
if (PlatformServices.Default != null)
if (PlatformServices.Default?.Application != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Application));
}
if (PlatformServices.Default?.Runtime != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Runtime));
}
if (PlatformServices.Default?.AssemblyLoadContextAccessor != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoadContextAccessor));
}
if (PlatformServices.Default?.AssemblyLoaderContainer != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoaderContainer));
}
if (PlatformServices.Default?.LibraryManager != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.LibraryManager));
}