2 using System.Collections.Generic;
5 using System.Reflection;
7 using System.Threading.Tasks;
8 using SiliconStudio.Core.Diagnostics;
10 namespace SiliconStudio.BuildEngine
12 public class PluginManager
14 public IEnumerable<string> PluginAssemblyLocations {
get {
return pluginAssemblyLocations; } }
16 private readonly List<string> pluginAssemblyLocations =
new List<string>();
18 private readonly
Logger logger;
27 AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => LoadAssembly(
new AssemblyName(e.Name));
32 return LoadAssembly(assemblyName.Name);
37 foreach (
string pluginLocation
in pluginAssemblyLocations)
39 if (pluginLocation != assemblyName)
41 string fileName = Path.GetFileNameWithoutExtension(pluginLocation);
42 if (fileName != assemblyName)
47 logger.Debug(
"Loading plugin: {0}", pluginLocation);
48 return Assembly.LoadFrom(pluginLocation);
55 foreach (
string pluginLocation
in pluginAssemblyLocations)
57 if (pluginLocation != assemblyFileName)
59 string fileName = Path.GetFileName(pluginLocation);
60 if (fileName != assemblyFileName)
65 logger.Debug(
"Loading plugin: {0}", pluginLocation);
66 return pluginLocation;
73 pluginAssemblyLocations.Add(filePath);
78 if (!Directory.Exists(folder))
81 foreach (
string filePath
in Directory.EnumerateFiles(folder,
"*.dll"))
84 logger.Debug(
"Detected plugin: {0}", Path.GetFileNameWithoutExtension(filePath));
85 pluginAssemblyLocations.Add(filePath);
Assembly LoadAssembly(string assemblyName)
void AddPlugin(string filePath)
Assembly LoadAssembly(AssemblyName assemblyName)
Base implementation for ILogger.
PluginManager(Logger logger=null)
void AddPluginFolder(string folder)
string FindAssembly(string assemblyFileName)