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:
Praburaj 2014-05-08 21:08:28 -07:00
parent 7ba4ba82b1
commit ab0dc92eb6
3 changed files with 1 additions and 30 deletions

View File

@ -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
{
}
}

View File

@ -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; }
}
}

View File

@ -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);