parent
0085022c02
commit
5bcc76d32c
|
|
@ -1,25 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
|
||||||
{
|
|
||||||
public class ApplicationDiscriminator : IApplicationDiscriminator
|
|
||||||
{
|
|
||||||
private readonly IHostingEnvironment _hostingEnvironment;
|
|
||||||
|
|
||||||
public ApplicationDiscriminator(IHostingEnvironment hostingEnvironment)
|
|
||||||
{
|
|
||||||
if (hostingEnvironment == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(hostingEnvironment));
|
|
||||||
}
|
|
||||||
|
|
||||||
_hostingEnvironment = hostingEnvironment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Discriminator => _hostingEnvironment.ContentRootPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="$(AspNetCoreVersion)" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(AspNetCoreVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="$(AspNetCoreVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(AspNetCoreVersion)" />
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
|
||||||
using Microsoft.AspNetCore.Hosting.Builder;
|
using Microsoft.AspNetCore.Hosting.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting.Internal;
|
using Microsoft.AspNetCore.Hosting.Internal;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
@ -298,7 +297,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.AddSingleton(_hostingEnvironment);
|
services.AddSingleton(_hostingEnvironment);
|
||||||
services.AddSingleton(_context);
|
services.AddSingleton(_context);
|
||||||
services.AddTransient<IApplicationDiscriminator, ApplicationDiscriminator>();
|
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.SetBasePath(_hostingEnvironment.ContentRootPath)
|
.SetBasePath(_hostingEnvironment.ContentRootPath)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting.Fakes;
|
using Microsoft.AspNetCore.Hosting.Fakes;
|
||||||
using Microsoft.AspNetCore.Hosting.Internal;
|
using Microsoft.AspNetCore.Hosting.Internal;
|
||||||
|
|
@ -989,19 +988,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void Build_SetsAppDescriminatorFromContentRoot()
|
|
||||||
{
|
|
||||||
var builder = CreateWebHostBuilder()
|
|
||||||
.UseContentRoot(Environment.CurrentDirectory)
|
|
||||||
.Configure(app => { })
|
|
||||||
.UseServer(new TestServer());
|
|
||||||
|
|
||||||
var host = builder.Build();
|
|
||||||
var applicationDiscriminator = host.Services.GetRequiredService<IApplicationDiscriminator>();
|
|
||||||
Assert.Equal(Environment.CurrentDirectory, applicationDiscriminator.Discriminator);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Build_DoesNotThrowIfUnloadableAssemblyNameInHostingStartupAssembliesAndCaptureStartupErrorsTrue()
|
public async Task Build_DoesNotThrowIfUnloadableAssemblyNameInHostingStartupAssembliesAndCaptureStartupErrorsTrue()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue