Small tweaks to hosting
- Added some framework assemblies to stop VS from complaining - Call AddSingleton instead of TryAddSigleton since we're always first. - Remove the null check since these abstractions are never null now. - Moved comments
This commit is contained in:
parent
fb036a4e3a
commit
a0de7564e2
|
|
@ -3,11 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.AspNetCore.Http.Features.Internal;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Internal;
|
using Microsoft.AspNetCore.Http.Internal;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.ObjectPool;
|
using Microsoft.Extensions.ObjectPool;
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
|
|
@ -221,8 +220,11 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
configureLogging(_loggerFactory);
|
configureLogging(_loggerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
services.AddSingleton(_loggerFactory); //The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one.
|
//The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one.
|
||||||
services.AddLogging(); //This is required to add ILogger of T.
|
services.AddSingleton(_loggerFactory);
|
||||||
|
|
||||||
|
//This is required to add ILogger of T.
|
||||||
|
services.AddLogging();
|
||||||
|
|
||||||
services.AddTransient<IStartupLoader, StartupLoader>();
|
services.AddTransient<IStartupLoader, StartupLoader>();
|
||||||
|
|
||||||
|
|
@ -239,17 +241,12 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
|
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
|
||||||
|
|
||||||
// Ensure object pooling is available everywhere.
|
// Ensure object pooling is available everywhere.
|
||||||
services.TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
||||||
|
|
||||||
var defaultPlatformServices = PlatformServices.Default;
|
var defaultPlatformServices = PlatformServices.Default;
|
||||||
if (defaultPlatformServices.Application != null)
|
|
||||||
{
|
services.AddSingleton(defaultPlatformServices.Application);
|
||||||
services.TryAddSingleton(defaultPlatformServices.Application);
|
services.AddSingleton(defaultPlatformServices.Runtime);
|
||||||
}
|
|
||||||
if (defaultPlatformServices.Runtime != null)
|
|
||||||
{
|
|
||||||
services.TryAddSingleton(defaultPlatformServices.Runtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var configureServices in _configureServicesDelegates)
|
foreach (var configureServices in _configureServicesDelegates)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,12 @@
|
||||||
"frameworkAssemblies": {
|
"frameworkAssemblies": {
|
||||||
"System.Runtime": {
|
"System.Runtime": {
|
||||||
"type": "build"
|
"type": "build"
|
||||||
|
},
|
||||||
|
"System.ComponentModel": {
|
||||||
|
"type": "build"
|
||||||
|
},
|
||||||
|
"System.IO": {
|
||||||
|
"type": "build"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue