using System.Collections.Generic;
using System.Reflection;
using BepInEx.Configuration;
using BepInEx.Logging;
namespace BepInEx.Preloader.Core.Patching;
///
/// A patcher provider that can discover and load assemblies containing patcher plugins
///
public abstract class BasePatcherProvider
{
protected BasePatcherProvider()
{
Info = PatcherPluginInfoAttribute.FromType(GetType());
Log = Logger.CreateLogSource(Info.Name);
Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, Info.GUID + ".cfg"), false,
new BepInPlugin(Info.GUID, Info.Name, Info.Version.ToString()));
}
///
/// A instance created for use by this patcher plugin provider.
///
public ManualLogSource Log { get; }
///
/// A configuration file binding created with the of this provider as the
/// filename.
///
public ConfigFile Config { get; }
///
/// Metadata associated with this patcher plugin provider.
///
public PatcherPluginInfoAttribute Info { get; }
///
/// Obtains a list of assemblies containing patchers to load
///
/// A list of load context, one per assembly
public abstract IList GetPatchers();
///
/// 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;
}
}