/// <inheritdoc /> public DispatchResult Execute(ExecutionContext context, CilInstruction instruction) { var eventArgs = new BeforeInstructionDispatchEventArgs <CilInstruction>(context, instruction); OnBeforeInstructionDispatch(eventArgs); DispatchResult result; if (eventArgs.Handled) { result = eventArgs.ResultOverride; } else { var handler = GetOpCodeHandler(instruction); result = handler.Execute(context, instruction); } OnAfterInstructionDispatch(new AfterInstructionDispatchEventArgs <CilInstruction>(context, instruction, result)); return(result); }
/// <summary> /// Invoked when an instruction is about to be dispatched. /// </summary> /// <param name="e">The arguments describing the event.</param> protected virtual void OnBeforeInstructionDispatch(BeforeInstructionDispatchEventArgs <CilInstruction> e) { BeforeInstructionDispatch?.Invoke(this, e); }