Hosting API review # 2
1. Moving HostingUtilities and PipelineInstance into internal namespaces. 2. Renaming some properties in IHostingEnvironment 3. Renaming IHttpContextAccessor HttpContext into Value. Addresses: https://github.com/aspnet/Hosting/issues/159 https://github.com/aspnet/Hosting/issues/157 https://github.com/aspnet/Hosting/issues/161
This commit is contained in:
parent
eb2887e5ef
commit
6bf5eabd9f
|
|
@ -9,8 +9,8 @@ namespace Microsoft.AspNet.Hosting
|
|||
{
|
||||
string EnvironmentName { get; set; }
|
||||
|
||||
string WebRoot { get; }
|
||||
string WebRootPath { get; }
|
||||
|
||||
IFileProvider WebRootFileProvider { get; set; }
|
||||
IFileProvider WebRootFileProvider { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNet.Hosting.Builder;
|
||||
using Microsoft.AspNet.Hosting.Internal;
|
||||
using Microsoft.AspNet.Hosting.Server;
|
||||
using Microsoft.AspNet.Hosting.Startup;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Hosting.Internal;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
|
|
@ -14,8 +15,8 @@ namespace Microsoft.AspNet.Hosting
|
|||
public HostingEnvironment(IApplicationEnvironment appEnvironment, IEnumerable<IConfigureHostingEnvironment> configures)
|
||||
{
|
||||
EnvironmentName = DefaultEnvironmentName;
|
||||
WebRoot = HostingUtilities.GetWebRoot(appEnvironment.ApplicationBasePath);
|
||||
WebRootFileProvider = new PhysicalFileProvider(WebRoot);
|
||||
WebRootPath = HostingUtilities.GetWebRoot(appEnvironment.ApplicationBasePath);
|
||||
WebRootFileProvider = new PhysicalFileProvider(WebRootPath);
|
||||
foreach (var configure in configures)
|
||||
{
|
||||
configure.Configure(this);
|
||||
|
|
@ -24,8 +25,8 @@ namespace Microsoft.AspNet.Hosting
|
|||
|
||||
public string EnvironmentName { get; set; }
|
||||
|
||||
public string WebRoot { get; private set; }
|
||||
public string WebRootPath { get; private set; }
|
||||
|
||||
public IFileProvider WebRootFileProvider { get; set; }
|
||||
public IFileProvider WebRootFileProvider { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using System.IO;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
namespace Microsoft.AspNet.Hosting.Internal
|
||||
{
|
||||
public static class HostingUtilities
|
||||
{
|
||||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNet.Builder;
|
|||
using Microsoft.AspNet.FeatureModel;
|
||||
using Microsoft.AspNet.Hosting.Builder;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
namespace Microsoft.AspNet.Hosting.Internal
|
||||
{
|
||||
public class PipelineInstance : IDisposable
|
||||
{
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Hosting.Internal;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Server
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Hosting.Startup
|
|||
{
|
||||
if (string.IsNullOrEmpty(applicationName))
|
||||
{
|
||||
throw new ArgumentException("applicationName");
|
||||
throw new ArgumentException("Value cannot be null or empty.", "applicationName");
|
||||
}
|
||||
|
||||
var assembly = Assembly.Load(new AssemblyName(applicationName));
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Hosting
|
|||
{
|
||||
var services = HostingServices.Create().BuildServiceProvider();
|
||||
var env = services.GetRequiredService<IHostingEnvironment>();
|
||||
Assert.Equal(Path.GetFullPath("testroot"), env.WebRoot);
|
||||
Assert.Equal(Path.GetFullPath("testroot"), env.WebRootPath);
|
||||
Assert.True(env.WebRootFileProvider.GetFileInfo("TextFile.txt").Exists);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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 Microsoft.AspNet.Hosting.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Tests
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.TestHost
|
|||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
var env = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
||||
Assert.Equal(Directory.GetCurrentDirectory(), env.WebRoot);
|
||||
Assert.Equal(Directory.GetCurrentDirectory(), env.WebRootPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue