using System; using System.Collections.Generic; using System.Collections.Concurrent; using System.Linq; namespace Prise.Caching { public class DefaultScopedPluginCache : IPluginCache { protected ConcurrentBag pluginCache; public DefaultScopedPluginCache() { this.pluginCache = new ConcurrentBag(); } public void Add(IAssemblyShim pluginAssembly, IEnumerable hostTypes = null) { this.pluginCache.Add(new CachedPluginAssembly { AssemblyShim = pluginAssembly, HostTypes = hostTypes }); } public void Remove(string assemblyName) { this.pluginCache = new ConcurrentBag(this.pluginCache.Where(a => a.AssemblyShim.Assembly.GetName().Name != assemblyName)); } public ICachedPluginAssembly[] GetAll() => this.pluginCache.ToArray(); } }