summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-03-25 15:17:26 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-03-25 15:17:26 -0400
commit7b641d816466fe7d9229374c175f59ee32b8dc5c (patch)
tree6ed0c1036071b1eba0ca181a2c9257fbfeeedde8 /src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
parent267e2469da290cbdb93bd58cea0272de403bbdab (diff)
downloadSMAPI-7b641d816466fe7d9229374c175f59ee32b8dc5c.tar.gz
SMAPI-7b641d816466fe7d9229374c175f59ee32b8dc5c.tar.bz2
SMAPI-7b641d816466fe7d9229374c175f59ee32b8dc5c.zip
simplify CIL rewriter hierarchy
Diffstat (limited to 'src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs')
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
index 359ca63e..9d0184c6 100644
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
+++ b/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
@@ -1,11 +1,10 @@
using Mono.Cecil;
using Mono.Cecil.Cil;
-using StardewModdingAPI.AssemblyRewriters.Framework;
namespace StardewModdingAPI.AssemblyRewriters.Finders
{
/// <summary>Finds CIL instructions that reference a given event.</summary>
- public sealed class EventFinder : BaseMethodFinder
+ public sealed class EventFinder : IInstructionFinder
{
/*********
** Properties
@@ -21,7 +20,7 @@ namespace StardewModdingAPI.AssemblyRewriters.Finders
** Accessors
*********/
/// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public override string NounPhrase { get; }
+ public string NounPhrase { get; }
/*********
@@ -41,13 +40,15 @@ namespace StardewModdingAPI.AssemblyRewriters.Finders
/*********
** Protected methods
*********/
- /// <summary>Get whether a method reference should be rewritten.</summary>
+ /// <summary>Get whether a CIL instruction matches.</summary>
/// <param name="instruction">The IL instruction.</param>
- /// <param name="methodRef">The method reference.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
- protected override bool IsMatch(Instruction instruction, MethodReference methodRef, bool platformChanged)
+ public bool IsMatch(Instruction instruction, bool platformChanged)
{
- return methodRef.DeclaringType.FullName == this.FullTypeName
+ MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
+ return
+ methodRef != null
+ && methodRef.DeclaringType.FullName == this.FullTypeName
&& (methodRef.Name == "add_" + this.EventName || methodRef.Name == "remove_" + this.EventName);
}
}