Skip to content

Commit

Permalink
#20 Removed assembly discovery from files in favour of the current do…
Browse files Browse the repository at this point in the history
…main context
  • Loading branch information
TimoWolters committed Oct 6, 2021
1 parent 6d07812 commit c232794
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/LotsenApp.Client.Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,24 @@ private ILotsenAppPlugin[] LoadPluginsFromFile(string file)

private ILotsenAppPlugin[] DiscoverFromAssemblies()
{
var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "LotsenApp.Client.*.dll")
.Where(f => !f.EndsWith("Views.dll"));
var assemblies = files
.Select(f => f.Replace(".dll", "")
.Replace(".\\", "")
.Replace(AppDomain.CurrentDomain.BaseDirectory, ""))
.ToArray();
// var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "LotsenApp.Client.*.dll")
// .Where(f => !f.EndsWith("Views.dll"));
// var assemblies = files
// .Select(f => f.Replace(".dll", "")
// .Replace(".\\", "")
// .Replace(AppDomain.CurrentDomain.BaseDirectory, ""))
// .ToArray();
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Select(a => (a.GetName().Name, a.FullName))
.Where(f => !f.Name.EndsWith("Views") && f.Name.StartsWith("LotsenApp"))
.Select(f => f.FullName);
foreach (var assembly in assemblies)
{
try
{
if (assembly == null)
{
continue;
}
_logger.LogDebug($"Trying to load assembly {assembly}");
AppDomain.CurrentDomain.Load(assembly);
}
Expand Down

0 comments on commit c232794

Please sign in to comment.