public virtual PluginDescriptor LoadPlugin(CandidateDescriptor candidate, Action <Assembly> onAssemblyLoad = null) { var assemblyPath = Path.GetFullPath(candidate.AssemblyPath); var assemblyName = Path.GetFileNameWithoutExtension(assemblyPath); var assemblyDir = Path.GetDirectoryName(assemblyPath); Assembly assembly = LoadAssembly(assemblyPath, new AssemblyName(assemblyName)); DefaultPluginDependencyResolver.AddProbingPath(assemblyDir); if (onAssemblyLoad != null) #pragma warning disable IDE1005 // Delegate invocation can be simplified. { onAssemblyLoad(assembly); } #pragma warning restore IDE1005 // Delegate invocation can be simplified. var plugin = GetPluginFromAssembly(assembly); if (plugin != null) { return(new PluginDescriptor( plugin, (plugin as IPluginWithDescription)?.Description, candidate.ContentRoot, assembly)); } return(null); }
static AssemblyPluginLoader() { DefaultPluginDependencyResolver.Attach(); //Attach dependency resolver }