public IReadOnlyDictionary <string, FoundPluginDto> FindPluginsInAssemblies(string path) { var assemblyPluginInfos = new Dictionary <string, FoundPluginDto>(); (PluginLoadContext pluginLoadContext, IEnumerable <Assembly> assemblies) = GetAssembliesAndLoadContext(path); foreach (var assembly in assemblies) { foreach (var plugin in PluginUtils.GetValidPluginTypes(assembly)) { var pluginDto = new FoundPluginDto(plugin.Name, assembly.Location); assemblyPluginInfos.Add(plugin.Name, pluginDto); } } pluginLoadContext.Unload(); return(assemblyPluginInfos); }
public Dictionary <string, T> CreateIPluginsFromAssembly(Assembly assembly) { var iPluginsDictionary = new Dictionary <string, T>(); foreach (var type in PluginUtils.GetValidPluginTypes(assembly)) { var plugin = Activator.CreateInstance(type) as T; switch (plugin) { case null: continue; case IPlugin iPlugin: iPluginsDictionary.Add(iPlugin.Name, plugin); break; } } return(iPluginsDictionary); }