Back to Harmony

Class Patch

docs/api/HarmonyLib.Patch.html

2.4.2.04.7 KB
Original Source

Class Patch

A serializable patch

Inheritance

System.Object

Patch

Namespace : HarmonyLib
Assembly : 0Harmony.dll
Syntax
public class Patch : IComparable

Constructors

Patch(HarmonyMethod, Int32, String)

Creates a patch

Declaration
public Patch(HarmonyMethod method, int index, string owner)
Parameters
TypeNameDescription
HarmonyMethodmethod

The method of the patch

| | System.Int32 | index |

Zero-based index

| | System.String | owner |

An owner (Harmony ID)

|

Patch(MethodInfo, Int32, String, Int32, String[], String[], Boolean)

Creates a patch

Declaration
public Patch(MethodInfo patch, int index, string owner, int priority, string[] before, string[] after, bool debug)
Parameters
TypeNameDescription
System.Reflection.MethodInfopatch

The method of the patch

| | System.Int32 | index |

Zero-based index

| | System.String | owner |

An owner (Harmony ID)

| | System.Int32 | priority |

The priority, see Priority

| | System.String[] | before |

A list of Harmony IDs for patches that should run after this patch

| | System.String[] | after |

A list of Harmony IDs for patches that should run before this patch

| | System.Boolean | debug |

A flag that will log the replacement method via FileLog every time this patch is used to build the replacement, even in the future

|

Fields

after

Keep this patch after the patches indicated in the list of Harmony IDs

Declaration
public readonly string[] after
Field Value
TypeDescription
System.String[]

before

Keep this patch before the patches indicated in the list of Harmony IDs

Declaration
public readonly string[] before
Field Value
TypeDescription
System.String[]

debug

A flag that will log the replacement method via FileLog every time this patch is used to build the replacement, even in the future

Declaration
public readonly bool debug
Field Value
TypeDescription
System.Boolean

index

Zero-based index

Declaration
public readonly int index
Field Value
TypeDescription
System.Int32

innerMethod

For an infix patch, this defines the inner method that we will apply the patch to

Declaration
public readonly InnerMethod innerMethod
Field Value
TypeDescription
InnerMethod

owner

The owner (Harmony ID)

Declaration
public readonly string owner
Field Value
TypeDescription
System.String

priority

The priority, see Priority

Declaration
public readonly int priority
Field Value
TypeDescription
System.Int32

Properties

PatchMethod

The method of the static patch method

Declaration
public MethodInfo PatchMethod { get; set; }
Property Value
TypeDescription
System.Reflection.MethodInfo

Methods

CompareTo(Object)

Determines how patches sort

Declaration
public int CompareTo(object obj)
Parameters
TypeNameDescription
System.Objectobj

The other patch

|

Returns
TypeDescription
System.Int32

integer to define sort order (-1, 0, 1)

|

Equals(Object)

Determines whether patches are equal

Declaration
public override bool Equals(object obj)
Parameters
TypeNameDescription
System.Objectobj

The other patch

|

Returns
TypeDescription
System.Boolean

true if equal

|

Overrides

System.Object.Equals(System.Object)

GetHashCode()

Hash function

Declaration
public override int GetHashCode()
Returns
TypeDescription
System.Int32

A hash code

|

Overrides

System.Object.GetHashCode()

GetMethod(MethodBase)

Get the patch method or a DynamicMethod if original patch method is a patch factory

Declaration
public MethodInfo GetMethod(MethodBase original)
Parameters
TypeNameDescription
System.Reflection.MethodBaseoriginal

The original method/constructor

|

Returns
TypeDescription
System.Reflection.MethodInfo

The method of the patch

|