aspnetcore/src/Microsoft.AspNet.Hosting/HostingServices.cs

57 lines
2.2 KiB
C#

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.AspNet.Hosting.Builder;
using Microsoft.AspNet.Hosting.Server;
using Microsoft.AspNet.Hosting.Startup;
using Microsoft.AspNet.Security.DataProtection;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Hosting
{
public static class HostingServices
{
public static IEnumerable<IServiceDescriptor> GetDefaultServices()
{
return GetDefaultServices(new Configuration());
}
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration)
{
var describer = new ServiceDescriber(configuration);
yield return describer.Transient<IHostingEngine, HostingEngine>();
yield return describer.Transient<IServerManager, ServerManager>();
yield return describer.Transient<IStartupManager, StartupManager>();
yield return describer.Transient<IStartupLoaderProvider, StartupLoaderProvider>();
yield return describer.Transient<IApplicationBuilderFactory, ApplicationBuilderFactory>();
yield return describer.Transient<IHttpContextFactory, HttpContextFactory>();
yield return describer.Singleton<ITypeActivator, TypeActivator>();
yield return describer.Instance<IApplicationLifetime>(new ApplicationLifetime());
// TODO: Do we expect this to be provide by the runtime eventually?
yield return describer.Singleton<ILoggerFactory, LoggerFactory>();
yield return describer.Scoped(typeof(IContextAccessor<>), typeof(ContextAccessor<>));
foreach (var service in OptionsServices.GetDefaultServices())
{
yield return service;
}
foreach (var service in DataProtectionServices.GetDefaultServices())
{
yield return service;
}
}
}
}