Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 0479102

Browse files
committed
Cleanup toggle Enabled logic
1 parent 93181f0 commit 0479102

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Hooks/HookInstance.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ private string GenerateDefaultPatchSourceCode(MethodInfo targetMethod)
182182

183183
public void TogglePatch()
184184
{
185-
Enabled = !Enabled;
186-
if (Enabled)
185+
if (!Enabled)
187186
Patch();
188187
else
189188
Unpatch();
@@ -194,6 +193,7 @@ public void Patch()
194193
try
195194
{
196195
patchProcessor.Patch();
196+
197197
Enabled = true;
198198
}
199199
catch (Exception ex)
@@ -214,6 +214,7 @@ public void Unpatch()
214214
patchProcessor.Unpatch(finalizer);
215215
if (transpiler != null)
216216
patchProcessor.Unpatch(transpiler);
217+
217218
Enabled = false;
218219
}
219220
catch (Exception ex)

0 commit comments

Comments
 (0)