示例#1
0
        public void Execute(AdviceSpec spec)
        {
            foreach (Navigator aspectNav in spec.AspectNavigators)
            {
                IMethodDefinition aspectMethod = Narrow.Interceptor(aspectNav, spec);
                foreach (Navigator targetNav in spec.TargetNavigators)
                {
                    MethodDefinition targetMethod = Narrow.ConcreteMethod(targetNav, spec);

                    // Prevent recursive weaving
                    if (targetMethod != aspectMethod &&
                        !Cil.BelongsToAspectDng(targetMethod) &&
                        !Cil.BelongsToAspectDng(aspectMethod) &&
                        targetMethod.GenericParameters.Count == 0 &&
                        targetMethod.DeclaringType.GenericParameters.Count == 0)
                    {
                        // Cannot keep semantics of "ref" parameters
                        if (targetMethod.ToString().IndexOf("&") == -1)
                        {
                            AddInterceptor(targetMethod, aspectMethod);
                        }
                    }
                }
            }
        }