Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Move runtime service registration
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Dec 15, 2015
1 parent e535777 commit ab5de9b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Microsoft.AspNet.Hosting/WebApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,23 @@ private IServiceCollection BuildHostingServices()
// Conjure up a RequestServices
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();

if (_configureServices != null)
var defaultPlatformServices = PlatformServices.Default;
if (defaultPlatformServices != null)
{
_configureServices(services);
if (defaultPlatformServices.Application != null)
{
services.TryAdd(ServiceDescriptor.Instance(defaultPlatformServices.Application));
}

if (defaultPlatformServices.Runtime != null)
{
services.TryAdd(ServiceDescriptor.Instance(defaultPlatformServices.Runtime));
}
}

if (PlatformServices.Default?.Application != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Application));
}

if (PlatformServices.Default?.Runtime != null)
if (_configureServices != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Runtime));
_configureServices(services);
}

return services;
Expand Down

0 comments on commit ab5de9b

Please sign in to comment.