コード例 #1
0
        public void Execute(AdviceSpec spec)
        {
            foreach (Navigator aspectNav in spec.AspectNavigators)
            {
                MethodDefinition aspectMethod = Narrow.Interceptor(aspectNav, spec);
                foreach (Navigator targetNav in spec.TargetNavigators)
                {
                    Instruction      targetCallInstruction = Narrow.Instruction(targetNav, spec);
                    MethodDefinition targetMethod          = Narrow.Method(targetNav.Parent, spec);

                    // We don't want to intercept volatile field accessors (marshalling problem)
                    string fieldTypeName = ((FieldReference)targetCallInstruction.Operand).FieldType.Name;
                    if (fieldTypeName.IndexOf(typeof(System.Runtime.CompilerServices.IsVolatile).Name) == -1)
                    {
                        AddInterceptor(targetCallInstruction, targetMethod, aspectMethod);
                    }
                }
            }
        }