Removing the IApplicationEnvironment interface from code
With a recent change the file based configuration source will automatically look for the file in the application base path. So getting the base path from IApplicationEnvironment service is no more necessary.
This commit is contained in:
parent
7ba4ba82b1
commit
ab0dc92eb6
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Microsoft.Framework.Runtime
|
||||
{
|
||||
[AssemblyNeutral]
|
||||
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
|
||||
public sealed class AssemblyNeutralAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Microsoft.Framework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Service provided by the host containing application environment details.
|
||||
/// </summary>
|
||||
[AssemblyNeutral]
|
||||
public interface IApplicationEnvironment
|
||||
{
|
||||
string ApplicationName { get; }
|
||||
string Version { get; }
|
||||
string ApplicationBasePath { get; }
|
||||
FrameworkName TargetFramework { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -35,9 +35,8 @@ public class Startup
|
|||
* Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
||||
* then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
||||
*/
|
||||
var applicationEnvironment = app.ApplicationServices.GetService<IApplicationEnvironment>();
|
||||
var configuration = new Configuration();
|
||||
configuration.AddJsonFile(Path.Combine(applicationEnvironment.ApplicationBasePath, "LocalConfig.json"));
|
||||
configuration.AddJsonFile("LocalConfig.json");
|
||||
configuration.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||
services.AddInstance<IConfiguration>(configuration);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue