private Tuple <PluginLoadContext, IEnumerable <Assembly> > Load(string path, LoadStrategyEnum multiple) { if (!Directory.Exists(path)) { throw new PluginException($"[{nameof(Load)}] The given path does not exist, path: {path}"); } if (multiple == LoadStrategyEnum.Multiple) { return(_pluginFinderService.GetAssembliesAndLoadContext(path)); } var(pluginLoadContext, assembly) = _pluginFinderService.GetAssemblyAndLoadContext(path); return(new Tuple <PluginLoadContext, IEnumerable <Assembly> >(pluginLoadContext, new[] { assembly })); }
public PluginLoadCommand(LoadStrategyEnum loadStrategyMultiple, string path) { LoadStrategyMultiple = loadStrategyMultiple; Path = path; }
public PluginLoadCommand(LoadStrategyEnum loadStrategyMultiple) : this(loadStrategyMultiple, string.Empty) { }
/// <inheritdoc cref="IPluginLoadService{T}.LoadAndAddToHomeAsync"/> public async Task <bool> LoadAndAddToHomeAsync(IEnumerable <string> assemblyPaths, LoadStrategyEnum multiple) { var paths = assemblyPaths.ToList(); if (paths.IsNullOrEmpty()) { return(false); } foreach (var path in paths) { (PluginLoadContext pluginLoadContext, IEnumerable <Assembly> assemblies) = Load(path, multiple); foreach (var assembly in assemblies) { await AddToHome(_pluginCreator.CreateIPluginsFromAssembly(assembly), assembly); } pluginLoadContext.Unload(); } return(true); }