示例#1
0
        /// <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);
        }
示例#2
0
 /// <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);
 }