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:
David Fowler 2016-03-29 03:03:40 -07:00
parent fb036a4e3a
commit a0de7564e2
3 changed files with 15 additions and 15 deletions

View File

@ -3,11 +3,8 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Features.Internal;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Hosting.Internal
{

View File

@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.PlatformAbstractions;
@ -221,8 +220,11 @@ namespace Microsoft.AspNetCore.Hosting
configureLogging(_loggerFactory);
}
services.AddSingleton(_loggerFactory); //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.
//The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one.
services.AddSingleton(_loggerFactory);
//This is required to add ILogger of T.
services.AddLogging();
services.AddTransient<IStartupLoader, StartupLoader>();
@ -239,17 +241,12 @@ namespace Microsoft.AspNetCore.Hosting
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
// Ensure object pooling is available everywhere.
services.TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
var defaultPlatformServices = PlatformServices.Default;
if (defaultPlatformServices.Application != null)
{
services.TryAddSingleton(defaultPlatformServices.Application);
}
if (defaultPlatformServices.Runtime != null)
{
services.TryAddSingleton(defaultPlatformServices.Runtime);
}
services.AddSingleton(defaultPlatformServices.Application);
services.AddSingleton(defaultPlatformServices.Runtime);
foreach (var configureServices in _configureServicesDelegates)
{

View File

@ -38,6 +38,12 @@
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
},
"System.ComponentModel": {
"type": "build"
},
"System.IO": {
"type": "build"
}
}
},