示例#1
0
        /// <summary>
        /// Weave the method.
        /// </summary>
        /// <param name="method">Method to be weaved.</param>
        /// <param name="plan">Weaving plan.</param>
        /// <param name="propertyName">Name of the property in case the method is a getter or setter method.</param>
        /// <param name="statistics">Weaving statistics.</param>
        public void Weave(MethodDefinition method, IWeavingPlan plan, string propertyName, ICanAddMethodWeavingRecord statistics)
        {
#if DEBUG
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            if (plan == null)
            {
                throw new ArgumentNullException("plan");
            }
#endif
            context.Reset();
            var methodSignature = method.GetSignature();
            var processor       = method.Body.GetILProcessor();

            AddLocalVariables(method, processor, plan);
            WeaveEntryJoinPoint(method, processor, plan.GetAdvices(JoinPoint.Entry), statistics, propertyName, methodSignature);
            WeaveExceptionJoinPoint(method, processor, plan.GetAdvices(JoinPoint.Exception), statistics, propertyName, methodSignature);
            WeaveExitJoinPoint(method, processor, plan.GetAdvices(JoinPoint.Exit), statistics, propertyName, methodSignature);
            WeaveSwitchInitialization(method, processor);
        }