// 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 GetDefaultServices() { return GetDefaultServices(new Configuration()); } public static IEnumerable GetDefaultServices(IConfiguration configuration) { var describer = new ServiceDescriber(configuration); yield return describer.Transient(); yield return describer.Transient(); yield return describer.Transient(); yield return describer.Transient(); yield return describer.Transient(); yield return describer.Transient(); yield return describer.Singleton(); yield return describer.Instance(new ApplicationLifetime()); // TODO: Do we expect this to be provide by the runtime eventually? yield return describer.Singleton(); 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; } } } }