Class BaseChainloader<TPlugin>

Inheritance
System.Object BaseChainloader<TPlugin> NetChainloader IL2CPPChainloader UnityChainloader
Inherited Members
System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace: BepInEx.Bootstrap
Assembly: BepInEx.Core.dll
Syntax
public abstract class BaseChainloader<TPlugin>
Type Parameters
Name Description
TPlugin

Fields

CurrentAssemblyName

Declaration
protected static readonly string CurrentAssemblyName
Field Value
Type Description
System.String

CurrentAssemblyVersion

Declaration
protected static readonly Version CurrentAssemblyVersion
Field Value
Type Description
System.Version

Properties

ConsoleTitle

Declaration
protected virtual string ConsoleTitle { get; }
Property Value
Type Description
System.String

DependencyErrors

Collection of error chainloader messages that occured during plugin loading. Contains information about what certain plugins were not loaded.

Declaration
public List<string> DependencyErrors { get; }
Property Value
Type Description
System.Collections.Generic.List<System.String>

Plugins

List of all PluginInfo instances loaded via the chainloader.

Declaration
public Dictionary<string, PluginInfo> Plugins { get; }
Property Value
Type Description
System.Collections.Generic.Dictionary<System.String, PluginInfo>

Methods

DiscoverPlugins()

Discovers plugins to load.

Declaration
protected virtual IList<PluginInfo> DiscoverPlugins()
Returns
Type Description
System.Collections.Generic.IList<PluginInfo>

List of plugins to be loaded.

DiscoverPluginsFrom(String, String)

Discovers all plugins in the plugin directory without loading them.

Declaration
protected IList<PluginInfo> DiscoverPluginsFrom(string path, string cacheName = "chainloader")
Parameters
Type Name Description
System.String path

Path from which to search the plugins.

System.String cacheName

Cache name to use. If null, results are not cached.

Returns
Type Description
System.Collections.Generic.IList<PluginInfo>

List of discovered plugins and their metadata.

Remarks

This is useful for discovering BepInEx plugin metadata.

Execute()

Run the chainloader and load all plugins from the plugins folder.

Declaration
public virtual void Execute()

HasBepinPlugins(AssemblyDefinition)

Declaration
protected static bool HasBepinPlugins(AssemblyDefinition ass)
Parameters
Type Name Description
AssemblyDefinition ass
Returns
Type Description
System.Boolean

Initialize(String)

Declaration
public virtual void Initialize(string gameExePath = null)
Parameters
Type Name Description
System.String gameExePath

InitializeLoggers()

Declaration
protected virtual void InitializeLoggers()

LoadPlugin(PluginInfo, Assembly)

Declaration
public abstract TPlugin LoadPlugin(PluginInfo pluginInfo, Assembly pluginAssembly)
Parameters
Type Name Description
PluginInfo pluginInfo
System.Reflection.Assembly pluginAssembly
Returns
Type Description
TPlugin

LoadPlugins(String[])

Detects and loads all plugins in the specified directories.

Declaration
public IList<PluginInfo> LoadPlugins(params string[] pluginsPaths)
Parameters
Type Name Description
System.String[] pluginsPaths

Directories to search the plugins from.

Returns
Type Description
System.Collections.Generic.IList<PluginInfo>

List of loaded plugin infos.

Remarks

It is better to collect all paths at once and use a single call to LoadPlugins than multiple calls. This allows to run proper dependency resolving and to load all plugins in one go.

ModifyLoadOrder(IList<PluginInfo>)

Preprocess the plugins and modify the load order.

Declaration
protected virtual IList<PluginInfo> ModifyLoadOrder(IList<PluginInfo> plugins)
Parameters
Type Name Description
System.Collections.Generic.IList<PluginInfo> plugins

Plugins to process.

Returns
Type Description
System.Collections.Generic.IList<PluginInfo>

List of plugins to load in the correct load order.

Remarks

Some plugins may be skipped if they cannot be loaded (wrong metadata, etc).

PluginTargetsWrongBepin(PluginInfo)

Declaration
protected static bool PluginTargetsWrongBepin(PluginInfo pluginInfo)
Parameters
Type Name Description
PluginInfo pluginInfo
Returns
Type Description
System.Boolean

ToPluginInfo(TypeDefinition, String)

Analyzes the given type definition and attempts to convert it to a valid PluginInfo

Declaration
public static PluginInfo ToPluginInfo(TypeDefinition type, string assemblyLocation)
Parameters
Type Name Description
TypeDefinition type

Type definition to analyze.

System.String assemblyLocation

The filepath of the assembly, to keep as metadata.

Returns
Type Description
PluginInfo

If the type represent a valid plugin, returns a PluginInfo instance. Otherwise, return null.

Events

Finished

Occurs after all plugins are loaded.

Declaration
public event Action Finished
Event Type
Type Description
System.Action

PluginLoaded

Occurs after a plugin is loaded.

Declaration
public event Action<PluginInfo> PluginLoaded
Event Type
Type Description
System.Action<PluginInfo>