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

Adding IApplicationLifetime to the manifest #176

Merged
merged 2 commits into from
Mar 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Microsoft.AspNet.Hosting/HostingServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ private class HostingManifest : IServiceManifest
public HostingManifest(IServiceProvider fallback)
{
var manifest = fallback.GetRequiredService<IServiceManifest>();
Services = new Type[] { typeof(ITypeActivator), typeof(IHostingEnvironment), typeof(ILoggerFactory), typeof(IHttpContextAccessor) }
.Concat(manifest.Services).Distinct();
Services = new Type[] {
typeof(ITypeActivator),
typeof(IHostingEnvironment),
typeof(ILoggerFactory),
typeof(ILogger<>),
typeof(IHttpContextAccessor),
typeof(IApplicationLifetime)
}.Concat(manifest.Services).Distinct();
}

public IEnumerable<Type> Services { get; private set; }
Expand Down
15 changes: 7 additions & 8 deletions test/Microsoft.AspNet.Hosting.Tests/UseRequestServicesFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting.Builder;
using Microsoft.AspNet.Hosting.Server;
using Microsoft.AspNet.Http.Core;
using Microsoft.AspNet.RequestContainer;
using Microsoft.Framework.DependencyInjection;
Expand Down Expand Up @@ -81,22 +79,23 @@ public void EnsureRequestServicesSetsRequestServices(bool initializeApplicationS
}

[Theory]
[InlineData(typeof(IHostingEngine))]
[InlineData(typeof(IServerLoader))]
[InlineData(typeof(IApplicationBuilderFactory))]
[InlineData(typeof(IHttpContextFactory))]
[InlineData(typeof(ITypeActivator))]
[InlineData(typeof(IApplicationLifetime))]
[InlineData(typeof(IHostingEnvironment))]
[InlineData(typeof(ILoggerFactory))]
[InlineData(typeof(ILogger<IHostingEngine>))]
[InlineData(typeof(IHttpContextAccessor))]
[InlineData(typeof(IApplicationLifetime))]
public void UseRequestServicesHostingImportedServicesAreDefined(Type service)
{
var baseServiceProvider = HostingServices.Create().BuildServiceProvider();
var builder = new ApplicationBuilder(baseServiceProvider);

builder.UseRequestServices();

Assert.NotNull(builder.ApplicationServices.GetRequiredService(service));
var fromAppServices = builder.ApplicationServices.GetRequiredService(service);

Assert.NotNull(fromAppServices);
Assert.Equal(baseServiceProvider.GetRequiredService(service), fromAppServices);
}
}
}