Beispiel #1
0
        /// <summary>
        /// Determines whether or not the method rewriter should replace the <paramref name="oldInstruction"/>.
        /// </summary>
        /// <remarks>The <see cref="InterceptFieldAccess"/> class only modifies instructions that get or set the value of static and instance fields.</remarks>
        /// <param name="oldInstruction">The instruction that is currently being evaluated.</param>
        /// <param name="hostMethod">The method that hosts the current instruction.</param>
        /// <returns><c>true</c> if the method should be replaced; otherwise, it should return <c>false</c>.</returns>
        protected override bool ShouldReplace(Instruction oldInstruction, MethodDefinition hostMethod)
        {
            if (!_fieldInstructions.Contains(oldInstruction.OpCode))
            {
                return(false);
            }

            // Match the field filter
            var targetField = (FieldReference)oldInstruction.Operand;

            return(_filter.ShouldWeave(hostMethod, targetField));
        }