mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use ConcurrentDictionary instead of List
This commit is contained in:
parent
256bfb7237
commit
78d8dbbc14
1 changed files with 8 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -14,14 +15,17 @@ namespace Flow.Launcher.Core.Plugin
|
|||
|
||||
private readonly AssemblyName assemblyName;
|
||||
|
||||
private static readonly List<Assembly> loadedAssembly;
|
||||
private static readonly ConcurrentDictionary<string, object> loadedAssembly;
|
||||
|
||||
static PluginAssemblyLoader()
|
||||
{
|
||||
loadedAssembly = new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
|
||||
var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
loadedAssembly = new ConcurrentDictionary<string, object>(
|
||||
currentAssemblies.Select(x => new KeyValuePair<string, object>(x.FullName, null)));
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
|
||||
{
|
||||
loadedAssembly.Add(args.LoadedAssembly);
|
||||
loadedAssembly[args.LoadedAssembly.FullName] = null;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +61,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
|
||||
internal bool ExistsInReferencedPackage(AssemblyName assemblyName)
|
||||
{
|
||||
if (loadedAssembly.Any(a => a.FullName == assemblyName.FullName))
|
||||
return true;
|
||||
return false;
|
||||
return loadedAssembly.ContainsKey(assemblyName.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue