From 10ecaeba6572fef0e4ba2a4eb8d5251f8dd91051 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 5 Jan 2016 15:35:32 -0800 Subject: [PATCH] Rename Load() to Instance for DependencyContext --- .../DependencyContext.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs index 4a62481cd..1294d70fc 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs @@ -12,6 +12,8 @@ namespace Microsoft.Extensions.DependencyModel { private const string DepsResourceSufix = ".deps.json"; + private static Lazy _defaultContext = new Lazy(LoadDefault); + public DependencyContext(string target, string runtime, CompilationOptions compilationOptions, Library[] compileLibraries, Library[] runtimeLibraries) { Target = target; @@ -21,6 +23,8 @@ namespace Microsoft.Extensions.DependencyModel RuntimeLibraries = runtimeLibraries; } + public static DependencyContext Default => _defaultContext.Value; + public string Target { get; } public string Runtime { get; } @@ -31,7 +35,7 @@ namespace Microsoft.Extensions.DependencyModel public IReadOnlyList RuntimeLibraries { get; } - public static DependencyContext Load() + private static DependencyContext LoadDefault() { var entryAssembly = (Assembly)typeof(Assembly).GetTypeInfo().GetDeclaredMethod("GetEntryAssembly").Invoke(null, null); var stream = entryAssembly.GetManifestResourceStream(entryAssembly.GetName().Name + DepsResourceSufix);