using System; using System.Collections.Generic; using System.IO; using System.Reflection; using BepInEx.Configuration; using BepInEx.Logging; namespace BepInEx; /// /// The base plugin provider type that is used by the BepInEx plugin loader. /// public abstract class BasePluginProvider { /// /// Create a new instance of a plugin provider and all of its tied in objects. /// /// BepInPluginProvider attribute is missing. protected BasePluginProvider() { var metadata = MetadataHelper.GetPluginProviderMetadata(this); if (metadata == null) throw new InvalidOperationException("Can't create an instance of " + GetType().FullName + " because it inherits from BasePluginProvider and the BepInPluginProvider attribute is missing."); Info = new PluginInfo { Metadata = metadata, Instance = this, Dependencies = MetadataHelper.GetDependencies(GetType()), Processes = MetadataHelper.GetAttributes(GetType()), }; Logger = BepInEx.Logging.Logger.CreateLogSource(metadata.Name); Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata); } /// /// Information about this plugin provider as it was loaded. /// public PluginInfo Info { get; } /// /// Logger instance tied to this plugin provider. /// protected ManualLogSource Logger { get; } /// /// Default config file tied to this plugin provider. The config file will not be created until /// any settings are added and changed, or is called. /// public ConfigFile Config { get; } /// /// Obtains a list of assemblies containing plugins to load /// /// A list of load context, one per assembly public abstract IList GetPlugins(); /// /// A custom assembly resolver that can be used by this provider to resolve assemblies /// that have failed to resolve /// /// The assembly's name /// The resolved assembly or null if the assembly couldn't be resolved public virtual Assembly ResolveAssembly(string name) { return null; } }