C# Class OTAPI.Patcher.Engine.Patcher

Contains the meat of the patcher, organises the source assembly, and a list of all the modification instances that will run against the source assembly.
Show file Open project: DeathCradle/Open-Terraria-API Class Usage Examples

Protected Properties

Property Type Description
modificationAssemblyGlob IEnumerable
readerParams ReaderParameters
resolver NugetAssemblyResolver

Public Methods

Method Description
AllowDuplicateModificationTypes ( System allowedTypes ) : void

This will allow ILRepack to merge all our modifications into one assembly. In our case we define hooks in the same namespace across different modification assemblies, and of course ILRepack detects the conflict. By enumerating each type of the modifications, we add each full name to the allowed list.

Patcher ( string sourceAssemblyPath, IEnumerable modificationAssemblyGlob, string outputAssemblyPath ) : Mono.Cecil

Creates a new instance of the patcher with the specified source assembly path and a glob containing all the modification assemblies.

Run ( ) : void

Protected Methods

Method Description
Cleanup ( ) : void

Cleans up data after a successful patch

GlobModificationAssemblies ( ) : IEnumerable
LoadModification ( Type type ) : ModificationBase
LoadModificationAssemblies ( ) : void
LoadSourceAssembly ( ) : void
PackAssemblies ( ) : void
RemoveModificationsFromPackedAssembly ( ) : void

Removes all ModificationBase implementations from the output assembly. Additionally it will also remove references that were added due to ModificationBases being merged in.

RunModifications ( ) : void
SaveSourceAssembly ( ) : void

Private Methods

Method Description
CurrentDomain_AssemblyLoad ( object sender, AssemblyLoadEventArgs args ) : void
CurrentDomain_AssemblyResolve ( object sender, ResolveEventArgs args ) : Assembly
Resolver_OnResolved ( object sender, NugetAssemblyResolvedEventArgs e ) : void
Resolver_ResolveFailure ( object sender, Mono.Cecil.AssemblyNameReference reference ) : AssemblyDefinition

Method Details

AllowDuplicateModificationTypes() public method

This will allow ILRepack to merge all our modifications into one assembly. In our case we define hooks in the same namespace across different modification assemblies, and of course ILRepack detects the conflict. By enumerating each type of the modifications, we add each full name to the allowed list.
public AllowDuplicateModificationTypes ( System allowedTypes ) : void
allowedTypes System
return void

Cleanup() protected method

Cleans up data after a successful patch
protected Cleanup ( ) : void
return void

GlobModificationAssemblies() protected method

protected GlobModificationAssemblies ( ) : IEnumerable
return IEnumerable

LoadModification() protected method

protected LoadModification ( Type type ) : ModificationBase
type System.Type
return ModificationBase

LoadModificationAssemblies() protected method

protected LoadModificationAssemblies ( ) : void
return void

LoadSourceAssembly() protected method

protected LoadSourceAssembly ( ) : void
return void

PackAssemblies() protected method

protected PackAssemblies ( ) : void
return void

Patcher() public method

Creates a new instance of the patcher with the specified source assembly path and a glob containing all the modification assemblies.
public Patcher ( string sourceAssemblyPath, IEnumerable modificationAssemblyGlob, string outputAssemblyPath ) : Mono.Cecil
sourceAssemblyPath string Path to the source assembly that modifications need to applied to
modificationAssemblyGlob IEnumerable A list of globs that yields a list of modifications
outputAssemblyPath string Path for the modified assembly to be saved
return Mono.Cecil

RemoveModificationsFromPackedAssembly() protected method

Removes all ModificationBase implementations from the output assembly. Additionally it will also remove references that were added due to ModificationBases being merged in.
protected RemoveModificationsFromPackedAssembly ( ) : void
return void

Run() public method

public Run ( ) : void
return void

RunModifications() protected method

protected RunModifications ( ) : void
return void

SaveSourceAssembly() protected method

protected SaveSourceAssembly ( ) : void
return void

Property Details

modificationAssemblyGlob protected property

Glob pattern for the list of modification assemblies that will run against the source assembly.
protected IEnumerable modificationAssemblyGlob
return IEnumerable

readerParams protected property

protected ReaderParameters readerParams
return ReaderParameters

resolver protected property

protected NugetAssemblyResolver,OTAPI.Patcher.Engine resolver
return NugetAssemblyResolver