diff options
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs')
-rw-r--r-- | lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs b/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs index b65c5e6..c62dff9 100644 --- a/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs +++ b/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs @@ -104,22 +104,30 @@ namespace VNLib.Plugins.Extensions.Loading plugin.ThrowIfUnloaded(); ArgumentNullException.ThrowIfNull(assemblyName); + string[] searchDirs; + /* * Allow an assets directory to limit the scope of the search for the desired * assembly, otherwise search all plugins directories */ string? assetDir = plugin.GetAssetsPath(); - assetDir ??= plugin.GetPluginsPath(); + + searchDirs = assetDir is null + ? plugin.GetPluginSearchDirs() + : ([assetDir]); /* - * This should never happen since this method can only be called from a - * plugin context, which means this path was used to load the current plugin - */ - ArgumentNullException.ThrowIfNull(assetDir, "No plugin asset directory is defined for the current host configuration, this is likely a bug"); + * This should never happen since this method can only be called from a + * plugin context, which means this path was used to load the current plugin + */ + if (searchDirs.Length == 0) + { + throw new ArgumentException("No plugin asset directory is defined for the current host configuration, this is likely a bug"); + } //Get the first file that matches the search file - return Directory.EnumerateFiles(assetDir, assemblyName, searchOption).FirstOrDefault(); + return searchDirs.SelectMany(d => Directory.EnumerateFiles(d, assemblyName, searchOption)).FirstOrDefault(); } /// <summary> |