Rebased #713 on latest aspnet/Hosting

This commit is contained in:
Dorin Andreica 2016-04-19 11:38:32 +02:00
parent 933a2f5a1d
commit d2780734b2
2 changed files with 17 additions and 1 deletions

View File

@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Hosting
throw new ArgumentNullException(nameof(configureApp));
}
var startupAssemblyName = configureApp.Target.GetType().GetTypeInfo().Assembly.GetName().Name;
var startupAssemblyName = configureApp.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name;
return hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName)
.ConfigureServices(services =>

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting.Fakes;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.AspNetCore.Hosting.Server;
@ -478,6 +479,21 @@ namespace Microsoft.AspNetCore.Hosting
Assert.Equal(PlatformServices.Default.Application.ApplicationBasePath, appEnv.ApplicationBasePath);
}
[Fact]
public void Configure_SupportsStaticMethodDelegate()
{
var host = new WebHostBuilder()
.UseServer(new TestServer())
.Configure(StaticConfigureMethod)
.Build();
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
}
private static void StaticConfigureMethod(IApplicationBuilder app)
{ }
private IWebHostBuilder CreateWebHostBuilder()
{
var vals = new Dictionary<string, string>