private void WeaveExitJoinPoint( MethodDefinition method, ILProcessor processor, IReadOnlyCollection <IAdviceInfo> advices, ICanAddMethodWeavingRecord statistics, string propertyName, string methodSignature) { var instructions = new List <Instruction>(); if (advices != null && advices.Any()) { UpdateLocalVariablesOnExit(method, instructions, processor); // inject advices for (var i = 0; i < advices.Count; i++) { var advice = advices.ElementAt(i); CallAdvice(method, processor, advice, instructions, propertyName, methodSignature); var record = StatisticsFactory.InitializeWeavingRecord( JoinPoint.Exit, advice.AspectName, advice.Advice.GetFullName(), advice.Advice.GetSignatureWithTypeFullName(), i); statistics.AddWeavingRecord(record); } } CompleteWeavingExit(method, instructions, processor); }
/// <inheritdoc/> public IPropertyWeavingStatistics Build() { getterRecords = getterRecordsBuilder.Build(); getterRecordsBuilder = null; setterRecords = setterRecordsBuilder.Build(); setterRecordsBuilder = null; return(this); }
/// <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); }