Apply code review feedback

This commit is contained in:
Daniel Plaisted 2017-04-26 14:57:18 -07:00
parent 06c1cc5990
commit cc9e942ede
10 changed files with 33 additions and 15 deletions

View file

@ -13,11 +13,19 @@ namespace ConsoleApplication
{
Console.WriteLine("Hello Portable World!");
var coreAssembly = typeof(object).GetTypeInfo().Assembly;
string coreFolder = Path.GetDirectoryName(coreAssembly.Location);
string frameworkVersion = Path.GetFileName(coreFolder);
var depsFile = new FileInfo(GetDataFromAppDomain("FX_DEPS_FILE"));
string frameworkVersion = depsFile.Directory.Name;
Console.WriteLine($"I'm running on shared framework version {frameworkVersion}!");
}
public static string GetDataFromAppDomain(string propertyName)
{
var appDomainType = typeof(object).GetTypeInfo().Assembly?.GetType("System.AppDomain");
var currentDomain = appDomainType?.GetProperty("CurrentDomain")?.GetValue(null);
var deps = appDomainType?.GetMethod("GetData")?.Invoke(currentDomain, new[] { propertyName });
return deps as string;
}
}
}