internal TopMethodInterceptionAspectWeaver(IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { IMethodScopeWeaver getReturnValueWeaver = null; var @params = aspectDefinition.Member.GetParameters(); var byRefArgumentsStoreWeaver = aspectWeavingSettings.ByRefArgumentsStoreWeaver; if (argumentsWeavingSettings.IsFunction()) { getReturnValueWeaver = new TopGetReturnValueWeaver(aspectWeavingSettings, argumentsWeavingSettings); } argumentsWeavingSettings.Parameters = @params.ToArray(@param => @param.ParameterType); argumentsWeavingSettings.BindingsDependency = weavedType; argumentsWeaver = new TopMethodInterceptionArgumentsWeaver(aspectDefinition.Member, argumentsWeavingSettings, aspectWeavingSettings); if (!byRefArgumentsStoreWeaver.ContainsByRefParams) { if (getReturnValueWeaver.IsNotNull()) { methodScopeWeavers.Add(getReturnValueWeaver); } weaver = new MethodScopeWeaversQueue(methodScopeWeavers); } else { Action <ILGenerator> storeArgsIfNeededAction = byRefArgumentsStoreWeaver.StoreArgsIfNeeded; var finallyWeavers = new[] { storeArgsIfNeededAction.ToMethodScopeWeaver() }; weaver = new TryFinallyAspectWeaver(methodScopeWeavers, finallyWeavers, getReturnValueWeaver); } }
internal BindingRemoveEventInterceptionAspectWeaver(IEventAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { argumentsWeavingSettings.BindingsDependency = weavedType; argumentsWeavingSettings.Parameters = new[] { aspectDefinition.Member.EventHandlerType }; argumentsWeaver = new BindingEventInterceptionArgumentsWeaver(aspectDefinition, argumentsWeavingSettings, aspectWeavingSettings, bindingSettings); weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
internal TopSetPropertyInterceptionAspectWeaver(IPropertyAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { argumentsWeavingSettings.BindingsDependency = weavedType; argumentsWeavingSettings.Parameters = new[] { aspectDefinition.Member.PropertyType }; argumentsWeaver = new TopSetPropertyInterceptionArgumentsWeaver(aspectDefinition.Member, argumentsWeavingSettings, aspectWeavingSettings); weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
internal TopBindingMethodInterceptionAspectWeaver(IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { argumentsWeavingSettings.BindingsDependency = weavedType; argumentsWeaver = new TopBindingMethodInterceptionArgumentsWeaver(aspectDefinition.Member, argumentsWeavingSettings, aspectWeavingSettings); methodScopeWeavers.Add(new TopAspectArgsMappingWeaverImpl(aspectWeavingSettings, argumentsWeavingSettings)); ArgumentType = argumentsWeavingSettings.ArgumentType; weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
internal BindingMethodInterceptionAspectWeaver(Type topAspectInScopeArgType, IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { this.topAspectInScopeArgType = topAspectInScopeArgType; ArgumentType = argumentsWeavingSettings.ArgumentType; argumentsWeavingSettings.BindingsDependency = weavedType; argumentsWeaver = new BindingMethodInterceptionArgumentsWeaver(aspectDefinition.Member, topAspectInScopeArgType, argumentsWeavingSettings, aspectWeavingSettings); methodScopeWeavers.Add(new NestedAspectArgsMappingWeaver(topAspectInScopeArgType, aspectWeavingSettings, argumentsWeavingSettings)); weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
internal TopRaiseEventInterceptionAspectWeaver(IEventAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { argumentsWeavingSettings.BindingsDependency = weavedType; argumentsWeavingSettings.Parameters = new[] { aspectDefinition.Member.EventHandlerType }; argumentsWeaver = new TopRaiseEventInterceptionArgumentsWeaver(aspectDefinition, argumentsWeavingSettings, aspectWeavingSettings, bindingSettings); if (aspectDefinition.Member.IsFunction()) { methodScopeWeavers.Add(new TopGetReturnValueWeaver(aspectWeavingSettings, argumentsWeavingSettings)); } weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
public virtual void Weave(ILGenerator ilGenerator) { MethodScopeWeaversQueue methodScopeWeaversQueue = null; weavers.Add(new BeginExceptionBlockMethodScopeWeaver()); weavers.AddRange(tryWeavers); weavers.Add(new FinallyMethodScopeWeaver(finallyWeavers)); weavers.Add(new EndExceptionBlockMethodScopeWeaver()); if (returnValueWeaver.IsNotNull()) { weavers.Add(returnValueWeaver); } methodScopeWeaversQueue = new MethodScopeWeaversQueue(weavers); methodScopeWeaversQueue.Weave(ilGenerator); }
internal BindingMethodInterceptionAspectWeaver(IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { argumentsWeavingSetings.BindingsDependency = weavedType; argumentsWeaver = new BindingMethodInterceptionArgumentsWeaver(argumentsWeavingSetings, aspectWeavingSettings); if (argumentsWeavingSetings.IsFunction) { methodScopeWeavers.Add(new FunctionAspectArgsMappingWeaver(aspectWeavingSettings, argumentsWeavingSetings)); } else { methodScopeWeavers.Add(new ActionAspectArgsMappingWeaver(aspectWeavingSettings, argumentsWeavingSetings)); } ArgumentType = argumentsWeavingSetings.ArgumentType; weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
internal NestedMethodInterceptionAspectWeaver(Type previousAspectArgType, IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType) : base(aspectDefinition, aspectWeavingSettings, weavedType) { var argumentWeavingSettings = aspectDefinition.ToArgumentsWeavingSettings(); argumentWeavingSettings.BindingsDependency = weavedType; argumentsWeaver = new NestedMethodIntercpetionArgumentsWeaver(previousAspectArgType, aspectWeavingSettings, argumentWeavingSettings); if (argumentsWeavingSetings.IsFunction) { methodScopeWeavers.Add(new NestedFunctionAspectArgsMappingWeaver(previousAspectArgType, aspectWeavingSettings, argumentsWeavingSetings)); } else { methodScopeWeavers.Add(new NestedActionAspectArgsMappingWeaver(previousAspectArgType, aspectWeavingSettings, argumentsWeavingSetings)); } weaver = new MethodScopeWeaversQueue(methodScopeWeavers); }
public override void Weave(ILGenerator ilGenerator) { var weavers = new List <IMethodScopeWeaver>(); MethodScopeWeaversQueue methodScopeWeaversQueue = null; weavers.AddRange(entryWeavers); weavers.Add(new BeginExceptionBlockMethodScopeWeaver()); weavers.Add(new BeginExceptionBlockMethodScopeWeaver()); weavers.AddRange(tryWeavers); weavers.Add(new BeginCatchBlockMethodScopeWeaver(catchWeavers, tryCatchFinallySettings)); weavers.Add(new EndExceptionBlockMethodScopeWeaver()); weavers.Add(new FinallyMethodScopeWeaver(finallyWeavers)); weavers.Add(new EndExceptionBlockMethodScopeWeaver()); if (returnValueWeaver.IsNotNull()) { weavers.Add(returnValueWeaver); } methodScopeWeaversQueue = new MethodScopeWeaversQueue(weavers); methodScopeWeaversQueue.Weave(ilGenerator); }
internal AbstractOnMethodBoundaryAspectWeaver(IAspectWeaver nestedAspect, IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings) : base(aspectDefinition, aspectWeavingSettings) { IMethodScopeWeaver entryWeaver = null; IMethodScopeWeaver catchWeaver = null; Action <ILGenerator> storeArgsAction = null; IAdviceExpression selectedExpression = null; IMethodScopeWeaver storeArgsArgsWeaver = null; var finallyWeavers = new List <IMethodScopeWeaver>(); var adviceWeavingSettings = new AdviceWeavingSettings(aspectWeavingSettings, argumentsWeavingSetings); ArgumentType = argumentsWeavingSetings.ArgumentType; byRefArgumentsStoreWeaver = aspectWeavingSettings.ByRefArgumentsStoreWeaver; storeArgsAction = byRefArgumentsStoreWeaver.StoreArgsIfNeeded; storeArgsArgsWeaver = storeArgsAction.ToMethodScopeWeaver(); tryWeavers = new List <IMethodScopeWeaver>() { nestedAspect }; localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository; if (adviceDiscoveryVistor.HasOnMethodEntryAdvice) { selectedExpression = ResolveOnMethodEntryAdvice(); entryWeaver = selectedExpression.Reduce(adviceWeavingSettings); } if (adviceDiscoveryVistor.HasOnMethodSuccessAdvice) { selectedExpression = ResolveOnMethodSuccessAdvice(); tryWeavers.Add(selectedExpression.Reduce(adviceWeavingSettings)); } if (argumentsWeavingSetings.IsFunction) { OnFunctionWeavingDetected(); } if (adviceDiscoveryVistor.HasFinallyAdvice) { selectedExpression = ResolveFinallyAdvice(); finallyWeavers.Add(selectedExpression.Reduce(adviceWeavingSettings)); finallyWeavers.Add(storeArgsArgsWeaver); if (adviceDiscoveryVistor.HasOnMethodExceptionAdvice) { var aspectMember = aspectRepository.GetAspectFieldByType(aspectDefinition.Aspect.AspectType); var settings = new TryCatchFinallySettings(ArgumentType, aspectMember, localBuilderRepository); selectedExpression = ResolveOnMethodExceptionAdvice(); catchWeaver = selectedExpression.Reduce(adviceWeavingSettings); weaver = new TryCatchFinallyAspectWeaver(settings, entryWeaver, tryWeavers, catchWeaver, finallyWeavers, returnValueWeaver); } else { weaver = new OnMethodBoundaryTryFinallyAspectWeaver(entryWeaver, tryWeavers, finallyWeavers, returnValueWeaver); } } else { var weavers = new List <IMethodScopeWeaver> { entryWeaver }; if (!byRefArgumentsStoreWeaver.ContainsByRefParams) { weavers.AddRange(tryWeavers); if (returnValueWeaver.IsNotNull()) { weavers.Add(returnValueWeaver); } weaver = new MethodScopeWeaversQueue(weavers); } else { finallyWeavers.Add(storeArgsArgsWeaver); weaver = new OnMethodBoundaryTryFinallyAspectWeaver(entryWeaver, weavers, finallyWeavers, returnValueWeaver); } } }
internal FinallyMethodScopeWeaver(IEnumerable <IMethodScopeWeaver> finallyWeavers) { finallyWeaversQueue = new MethodScopeWeaversQueue(finallyWeavers); }