Beispiel #1
0
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var previousAspectArgsType = previousAspectDefinition.ToAspectArgumentImpl();
            var nestedWeaver           = aspectExpression.Reduce(aspectWeavingSettings);

            return(new NestedOnMethodBoundaryAspectWeaver(previousAspectArgsType, nestedWeaver, aspectDefinition, aspectWeavingSettings));
        }
 internal AspectArgsMethodWeaver(MethodInfo method, LocalBuilder methodLocalBuilder, Type[] parameters, IAspectWeavingSettings aspectWeavingSettings)
 {
     this.method = method;
     this.parameters = parameters;
     this.methodLocalBuilder = methodLocalBuilder;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
 internal AbstractMethodInterceptionBindingWeaver(IAspectExpression aspectExpression, IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings)
     : base(aspectDefinition)
 {
     this.aspectExpression      = aspectExpression;
     this.aspectWeavingSettings = aspectWeavingSettings;
     lazyWeavedType             = new Core.Lib.Lazy <FieldInfo>(WeaveType);
 }
        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);
            }
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var topAspectInScopeArgType = topAspectInScopeDefinition.ToAspectArgumentImpl();
            var bindingWeaver = new IsolatedMethodInterceptionBindingWeaver(aspectExpression, aspectDefinition, aspectWeavingSettings);

            return new NestedMethodInterceptionAspectWeaver(topAspectInScopeArgType, aspectDefinition, aspectWeavingSettings, bindingWeaver.WeavedType);
        }
 internal AbstractMethodInterceptionBindingWeaver(IAspectExpression aspectExpression, IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings)
     : base(aspectDefinition)
 {
     this.aspectExpression = aspectExpression;
     this.aspectWeavingSettings = aspectWeavingSettings;
     lazyWeavedType = new Core.Lib.Lazy<FieldInfo>(WeaveType);
 }
Beispiel #7
0
 internal AspectArgsMethodWeaver(MethodInfo method, LocalBuilder methodLocalBuilder, Type[] parameters, IAspectWeavingSettings aspectWeavingSettings)
 {
     this.method                = method;
     this.parameters            = parameters;
     this.methodLocalBuilder    = methodLocalBuilder;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
 internal AbstractMethodBindingWeaver(MethodInfo method, BindingSettings bindingSettings, IAspectWeavingSettings aspectWeavingSettings, IMethodScopeWeaver methodScopeWeaver)
 {
     this.method = method;
     this.bindingSettings = bindingSettings;
     this.methodScopeWeaver = methodScopeWeaver;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var topAspectInScopeArgType = topAspectInScopeDefinition.ToAspectArgumentImpl();
            var bindingWeaver           = new IsolatedMethodInterceptionBindingWeaver(aspectExpression, aspectDefinition, aspectWeavingSettings);

            return(new NestedMethodInterceptionAspectWeaver(topAspectInScopeArgType, aspectDefinition, aspectWeavingSettings, bindingWeaver.WeavedType));
        }
 internal AbstractMethodBindingWeaver(MethodInfo method, BindingSettings bindingSettings, IAspectWeavingSettings aspectWeavingSettings, IMethodScopeWeaver methodScopeWeaver)
 {
     this.method                = method;
     this.bindingSettings       = bindingSettings;
     this.methodScopeWeaver     = methodScopeWeaver;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
 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);
 }
Beispiel #12
0
 internal NestedMethodInvokerAspectWeaver(MethodInfo method, Type topAspectInScopeArgType, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
     : base(method, aspectWeavingSettings.WeavingSettings)
 {
     this.topAspectInScopeArgType = topAspectInScopeArgType;
     this.aspectWeavingSettings   = aspectWeavingSettings;
     byRefArgumentStoreWeaver     = aspectWeavingSettings.ByRefArgumentsStoreWeaver;
     argumentsWeaver = new NestedMethodInvokerArgumentsWeaver(method, topAspectInScopeArgType, aspectWeavingSettings, argumentsWeavingSettings);
 }
 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);
 }
Beispiel #14
0
 internal AbstractPropertyBindingWeaver(PropertyInfo property, BindingSettings bindingSettings, IAspectWeavingSettings aspectWeavingSettings, IMethodScopeWeaver getMethodScopeWeaver = null, IMethodScopeWeaver setMethodScopeWeaver = null)
 {
     this.property              = property;
     this.bindingSettings       = bindingSettings;
     this.getMethodScopeWeaver  = getMethodScopeWeaver;
     this.setMethodScopeWeaver  = setMethodScopeWeaver;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
 internal NestedMethodInvokerAspectWeaver(MethodInfo method, Type topAspectInScopeArgType, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
     : base(method, aspectWeavingSettings.WeavingSettings)
 {
     this.topAspectInScopeArgType = topAspectInScopeArgType;
     this.aspectWeavingSettings = aspectWeavingSettings;
     byRefArgumentStoreWeaver = aspectWeavingSettings.ByRefArgumentsStoreWeaver;
     argumentsWeaver = new NestedMethodInvokerArgumentsWeaver(method, topAspectInScopeArgType, aspectWeavingSettings, argumentsWeavingSettings);
 }
        internal TopBindingOnMethodBoundaryAspectWeaver(IAspectWeaver nestedWeaver, IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings settings)
            : base(nestedWeaver, aspectDefinition, settings)
        {
            var @params = aspectDefinition.Member.GetParameters();

            argumentsWeavingSettings.Parameters = @params.ToArray(@param => @param.ParameterType);
            argumentsWeaver = new TopBindingOnMethodExecutionArgumentsWeaver(aspectDefinition.Member, argumentsWeavingSettings, settings);
        }
        internal CompositeRaiseEventWeaver(IEventTypeBuilder eventTypeBuilder, EventInfo @event, MethodInfo method, IAspectDefinitionCollection aspectDefinitions, IAspectWeavingSettings aspectWeavingSettings)
            : base(eventTypeBuilder, method, aspectDefinitions, aspectWeavingSettings)
        {
            var typeBuilder = (IAspectTypeDefinition)aspectWeavingSettings.WeavingSettings.TypeDefinition;
            var eventFieldBuilder = typeBuilder.GetEventBrokerFielTypeDefinition(@event);

            methodSignatureWeaver = new RaiseEventMethodSignatureWeaver(eventTypeBuilder, typeBuilder, eventFieldBuilder);
        }
 internal AbstractPropertyBindingWeaver(PropertyInfo property, BindingSettings bindingSettings, IAspectWeavingSettings aspectWeavingSettings, IMethodScopeWeaver getMethodScopeWeaver = null, IMethodScopeWeaver setMethodScopeWeaver = null)
 {
     this.property = property;
     this.bindingSettings = bindingSettings;
     this.getMethodScopeWeaver = getMethodScopeWeaver;
     this.setMethodScopeWeaver = setMethodScopeWeaver;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
        internal BindingMethodAspectDecoratorWeaver(IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
            : base(aspectDefinition.Member, aspectWeavingSettings.WeavingSettings)
        {
            var bindingSettings = aspectDefinition.ToBindingSettings();

            methodDecoratorScopeWeaver = new MethodDecoratorScopeWeaver(aspectDefinition.Member, aspectWeavingSettings);
            weaver = new MethodDecoratorBindingWeaver(aspectDefinition.Member, bindingSettings, aspectWeavingSettings, this);
        }
 internal NestedMethodInvokerAspectWeaver(Type previousAspectArgType, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
     : base(aspectWeavingSettings.WeavingSettings)
 {
     this.previousAspectArgType    = previousAspectArgType;
     this.aspectWeavingSettings    = aspectWeavingSettings;
     this.argumentsWeavingSettings = argumentsWeavingSettings;
     byRefArgumentStoreWeaver      = aspectWeavingSettings.ByRefArgumentsStoreWeaver;
     argumentsWeaver = new NestedMethodInvokerArgumentsWeaver(previousAspectArgType, aspectWeavingSettings, argumentsWeavingSettings);
 }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var bindingWeaver = propertyBuilder.Build(aspectWeavingSettings);
            var clonedSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.LocalBuilderRepository = new LocalBuilderRepository();
            });

            return CreateWeaver(clonedSettings, bindingWeaver.WeavedType);
        }
 internal AdviceWeavingSettings(IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
 {
     AspectType = argumentsWeavingSettings.AspectType;
     ArgumentsWeavingSettings = argumentsWeavingSettings;
     WeavingSettings          = aspectWeavingSettings.WeavingSettings;
     AspectRepository         = aspectWeavingSettings.AspectRepository;
     AspectArgsMapper         = aspectWeavingSettings.AspectArgsMapper;
     LocalBuilderRepository   = aspectWeavingSettings.LocalBuilderRepository;
 }
Beispiel #23
0
 internal AdviceWeavingSettings(IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
 {
     AspectType = argumentsWeavingSettings.AspectType;
     ArgumentsWeavingSettings = argumentsWeavingSettings;
     WeavingSettings = aspectWeavingSettings.WeavingSettings;
     AspectRepository = aspectWeavingSettings.AspectRepository;
     AspectArgsMapper = aspectWeavingSettings.AspectArgsMapper;
     LocalBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
 }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var bindingWeaver  = propertyBuilder.Build(aspectWeavingSettings);
            var clonedSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.LocalBuilderRepository = new LocalBuilderRepository();
            });

            return(CreateWeaver(clonedSettings, bindingWeaver.WeavedType));
        }
        internal TopOnMethodBoundaryAspectWeaver(IAspectWeaver nestedWeaver, IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings)
            : base(nestedWeaver, aspectDefinition, aspectWeavingSettings)
        {
            var @params = aspectDefinition.Member.GetParameters();

            methodScopeWeavers = new List<IMethodScopeWeaver>();
            argumentsWeavingSettings.Parameters = @params.ToArray(@param => @param.ParameterType).ToArray();
            argumentsWeaver = new TopOnMethodBoundaryArgumentsWeaver(aspectDefinition.Member, argumentsWeavingSettings, aspectWeavingSettings);
        }
Beispiel #26
0
 internal IsolatedEventInterceptionBindingWeaver(IAspectExpression addAspectExpression, IAspectExpression removeAspectExpression, IAspectExpression invokeAspectExpression, IEventAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings)
     : base(aspectDefinition)
 {
     this.addAspectExpression    = addAspectExpression;
     this.aspectWeavingSettings  = aspectWeavingSettings;
     this.removeAspectExpression = removeAspectExpression;
     this.invokeAspectExpression = invokeAspectExpression;
     lazyWeavedType = new Core.Lib.Lazy <FieldInfo>(WeaveType);
 }
 internal MethodInvokerAspectWeaver(Type topAspectInScopeArgType, IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
     : base(aspectDefinition.Member, aspectWeavingSettings.WeavingSettings)
 {
     this.topAspectInScopeArgType = topAspectInScopeArgType;
     this.argumentsWeavingSettings = argumentsWeavingSettings;
     localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
     byRefArgumentStoreWeaver = aspectWeavingSettings.ByRefArgumentsStoreWeaver;
     argumentsWeaver = new MethodInvokerArgumentsWeaver(aspectDefinition.Member, topAspectInScopeArgType, aspectWeavingSettings, argumentsWeavingSettings, byRefArgumentStoreWeaver);
 }
 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);
 }
Beispiel #29
0
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedAspectWeavingSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.LocalBuilderRepository = new LocalBuilderRepository();
            });

            var bindingWeaver = new IsolatedGetPropertyInterceptionBindingWeaver(aspectExpression, aspectDefinition, clonedAspectWeavingSettings);

            return(new TopGetPropertyInterceptionAspectWeaver(aspectDefinition, clonedAspectWeavingSettings, bindingWeaver.WeavedType));
        }
Beispiel #30
0
 public EventInterceptionBindingWeaver(EventInfo @event, BindingSettings bindingSettings, IAspectWeavingSettings aspectWeavingSettings, IAspectWeaver addMethodScopeWeaver, IAspectWeaver removeMethodScopeWeaver, IAspectWeaver invokeMethodScopeWeaver)
 {
     this.@event                  = @event;
     this.bindingSettings         = bindingSettings;
     this.addMethodScopeWeaver    = addMethodScopeWeaver;
     this.aspectWeavingSettings   = aspectWeavingSettings;
     this.removeMethodScopeWeaver = removeMethodScopeWeaver;
     this.invokeMethodScopeWeaver = invokeMethodScopeWeaver;
     ResolveParameterTypes();
 }
 internal AbstractMethodAspectWeaver(IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWevingSettings)
 {
     advices = aspectDefinition.Advices;
     this.aspectDefinition      = aspectDefinition;
     this.aspectWeavingSettings = aspectWevingSettings;
     weavingSettings            = aspectWevingSettings.WeavingSettings;
     aspectRepository           = aspectWevingSettings.AspectRepository;
     argumentsWeavingSetings    = aspectDefinition.ToArgumentsWeavingSettings();
     aspectDefinition.Advices.ForEach(advice => advice.Accept(adviceDiscoveryVistor));
 }
        protected AbstractAspectMethodWeaver(MethodInfo method, IAspectDefinitionCollection aspectDefinitions, IAspectWeavingSettings aspectWeavingSettings)
        {
            IAspectExpression aspectExpression = null;
            var aspectExpressionBuilder = new AspectExpressionTreeBuilder(aspectDefinitions);

            this.method = method;
            methodEndWeaver = new MethodEndWeaver();
            aspectExpression = aspectExpressionBuilder.Build();
            methodScopeWeaver = aspectExpression.Reduce(aspectWeavingSettings);
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.ByRefArgumentsStoreWeaver = NullObjectByRefArgumentsStoreWeaver.Empty;
            });

            var nestedWeaver = aspectExpression.Reduce(clonedSettings);

            return(new BindingOnMethodBoundaryAspectWeaver(nestedWeaver, aspectDefinition, clonedSettings));
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedAspectWeavingSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.LocalBuilderRepository = new LocalBuilderRepository();
            });

            var bindingWeaver = new IsolatedSetPropertyInterceptionBindingWeaver(aspectExpression, aspectDefinition, clonedAspectWeavingSettings);

            return new BindingSetPropertyInterceptionAspectWeaver(aspectDefinition, aspectWeavingSettings, bindingWeaver.WeavedType);
        }
 public EventInterceptionBindingWeaver(EventInfo @event, BindingSettings bindingSettings, IAspectWeavingSettings aspectWeavingSettings, IAspectWeaver addMethodScopeWeaver, IAspectWeaver removeMethodScopeWeaver, IAspectWeaver invokeMethodScopeWeaver)
 {
     this.@event = @event;
     this.bindingSettings = bindingSettings;
     this.addMethodScopeWeaver = addMethodScopeWeaver;
     this.aspectWeavingSettings = aspectWeavingSettings;
     this.removeMethodScopeWeaver = removeMethodScopeWeaver;
     this.invokeMethodScopeWeaver = invokeMethodScopeWeaver;
     ResolveParameterTypes();
 }
 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);
 }
Beispiel #37
0
 internal AbstractAspectWeaver(IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings)
 {
     advices = aspectDefinition.Advices;
     this.aspectDefinition = aspectDefinition;
     this.aspectWeavingSettings = aspectWeavingSettings;
     bindingSettings = aspectDefinition.ToBindingSettings();
     weavingSettings = aspectWeavingSettings.WeavingSettings;
     aspectRepository = aspectWeavingSettings.AspectRepository;
     argumentsWeavingSettings = aspectDefinition.ToArgumentsWeavingSettings();
     aspectDefinition.Advices.ForEach(advice => advice.Accept(adviceDiscoveryVistor));
 }
        internal BindingAspectDecoratorWeaver(IAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
            : base(aspectWeavingSettings.WeavingSettings)
        {
            var bindingSettings = aspectDefinition.ToBindingSettings();
            var methodInfoImpl  = aspectWeavingSettings.WeavingSettings.MethodInfoImpl;

            lazyWeavedType = new Core.Lib.Lazy <FieldInfo>(WeaveType);
            bindingSettings.LocalBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
            methodDecoratorScopeWeaver             = new MethodDecoratorScopeWeaver(aspectWeavingSettings);
            weaver = new MethodDecoratorBindingWeaver(bindingSettings, aspectWeavingSettings, this);
        }
        internal MethodDecoratorScopeWeaver(MethodInfo method, IAspectWeavingSettings aspectWeavingSettings)
            : base(method, aspectWeavingSettings.WeavingSettings)
        {
            Type aspectArgumentContract = null;
            var localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;

            this.method = method;
            aspectArgumentContract = method.ToAspectArgumentContract();
            byRefArgumentsStoreWeaver = new MethodDecoratorByRefArgumentsStoreWeaver(aspectArgumentContract, method, localBuilderRepository);
            argumentsWeaver = new MethodDecoratorArgumentsWeaver(method, byRefArgumentsStoreWeaver);
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var topBindingArgType = aspectDefinition.ToAspectArgumentImpl();
            var clonedSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.ByRefArgumentsStoreWeaver = new BindingByRefArgumentsWeaverImpl(topBindingArgType, aspectDefinition.Member, settings.LocalBuilderRepository);
            });

            var nestedWeaver = aspectExpression.Reduce(clonedSettings);

            return new TopBindingOnMethodBoundaryAspectWeaver(nestedWeaver, aspectDefinition, clonedSettings);
        }
        internal BindingSetPropertyInterceptionAspectWeaver(IPropertyAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, FieldInfo weavedType)
            : base(aspectDefinition, aspectWeavingSettings, weavedType)
        {
            IMethodScopeWeaver finallyWeaver = null;

            argumentsWeavingSettings.BindingsDependency = weavedType;
            argumentsWeavingSettings.Parameters = new[] { aspectDefinition.Member.PropertyType };
            finallyWeaver = new FinallyBindingPropertyAspectWeaver(aspectDefinition.Member, argumentsWeavingSettings, aspectWeavingSettings);
            argumentsWeaver = new BindingSetPropertyInterceptionArgumentsWeaver(aspectDefinition.Member, argumentsWeavingSettings, aspectWeavingSettings);
            weaver = new TryFinallyAspectWeaver(methodScopeWeavers, new[] { finallyWeaver });
        }
Beispiel #42
0
        internal MethodDecoratorScopeWeaver(MethodInfo method, IAspectWeavingSettings aspectWeavingSettings)
            : base(method, aspectWeavingSettings.WeavingSettings)
        {
            Type aspectArgumentContract = null;
            var  localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;

            this.method               = method;
            aspectArgumentContract    = method.ToAspectArgumentContract();
            byRefArgumentsStoreWeaver = new MethodDecoratorByRefArgumentsStoreWeaver(aspectArgumentContract, method, localBuilderRepository);
            argumentsWeaver           = new MethodDecoratorArgumentsWeaver(method, byRefArgumentsStoreWeaver);
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var topBindingArgType = aspectDefinition.ToAspectArgumentImpl();
            var clonedSettings    = aspectWeavingSettings.CloneWith(settings => {
                settings.ByRefArgumentsStoreWeaver = new BindingByRefArgumentsWeaverImpl(topBindingArgType, aspectDefinition.Member, settings.LocalBuilderRepository);
            });

            var nestedWeaver = aspectExpression.Reduce(clonedSettings);

            return(new TopBindingOnMethodBoundaryAspectWeaver(nestedWeaver, aspectDefinition, clonedSettings));
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var topAspectInScopeArgType = topAspectInScopeDefinition.ToAspectArgumentImpl();

            var clonedSettings = aspectWeavingSettings.CloneWith(settings => {
                settings.ByRefArgumentsStoreWeaver = NullObjectByRefArgumentsStoreWeaver.Empty;
            });

            var nestedWeaver = aspectExpression.Reduce(clonedSettings);

            return new BindingOnMethodBoundaryAspectWeaver(topAspectInScopeArgType, nestedWeaver, aspectDefinition, clonedSettings);
        }
Beispiel #45
0
        public AspectsWeaver(IAspectExpression aspectExpression, IAspectDefinitionCollection aspectDefinitions, IWeavingSettings weavingSettings)
        {
            this.aspectExpression  = aspectExpression;
            aspectArgsMapperWeaver = new AspectArgsMapperWeaver();
            aspectAttributeWeaver  = new AspectsAttributeWeaver(aspectDefinitions);

            settings = new AspectWeavingSettingsImpl {
                WeavingSettings  = weavingSettings,
                AspectRepository = aspectAttributeWeaver,
                AspectArgsMapper = aspectArgsMapperWeaver
            };
        }
Beispiel #46
0
        internal MethodDecoratorScopeWeaver(IAspectWeavingSettings aspectWeavingSettings)
            : base(aspectWeavingSettings.WeavingSettings)
        {
            Type aspectArgumentContract = null;
            var  localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
            var  weavingSettings        = aspectWeavingSettings.WeavingSettings;

            this.aspectWeavingSettings = aspectWeavingSettings;
            methodInfoImpl             = aspectWeavingSettings.WeavingSettings.MethodInfoImpl;
            aspectArgumentContract     = methodInfoImpl.ToAspectArgumentContract();
            byRefArgumentsStoreWeaver  = new MethodDecoratorByRefArgumentsStoreWeaver(aspectArgumentContract, methodInfoImpl, localBuilderRepository);
            argumentsWeaver            = new MethodDecoratorArgumentsWeaver(methodInfoImpl, byRefArgumentsStoreWeaver);
        }
        internal AbstractAspectArgsMappingWeaver(IAspectWeavingSettings aspectWeavingSettings, IArgumentsSettings argumentsSettings)
        {
            Type[] @params = null;

            this.argumentsSettings = argumentsSettings;
            this.aspectWeavingSettings = aspectWeavingSettings;
            aspectArgumentType = argumentsSettings.ArgumentType;
            weavingSettings = aspectWeavingSettings.WeavingSettings;
            localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
            @params = argumentsSettings.ArgumentType.GetGenericArguments();
            parameters = argumentsSettings.Parameters;
            mappingParameters = @params.Skip(1).ToArray();
        }
        internal BindingRaiseEventInterceptionAspectWeaver(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);

            if (aspectDefinition.Member.IsFunction()) {
                methodScopeWeavers.Add(new TopGetReturnValueWeaver(aspectWeavingSettings, argumentsWeavingSettings));
            }

            weaver = new MethodScopeWeaversQueue(methodScopeWeavers);
        }
 internal AbstractArgumentsWeaver(IArgumentsWeavingSettings argumentsWeavingSettings, IAspectWeavingSettings aspectWeavingSettings)
 {
     ReturnType             = argumentsWeavingSettings.ReturnType;
     AspectType             = argumentsWeavingSettings.AspectType;
     Parameters             = new Type[argumentsWeavingSettings.Parameters.Length];
     LocalBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
     ArgumentType           = argumentsWeavingSettings.ArgumentType;
     argumentsWeavingSettings.Parameters.CopyTo(Parameters, 0);
     IsFunction = argumentsWeavingSettings.IsFunction;
     this.aspectWeavingSettings = aspectWeavingSettings;
     WeavingSettings            = aspectWeavingSettings.WeavingSettings;
     BindingsDependency         = argumentsWeavingSettings.BindingsDependency;
 }
Beispiel #50
0
        internal AbstractAspectArgsMappingWeaver(IAspectWeavingSettings aspectWeavingSettings, IArgumentsSettings argumentsSettings)
        {
            Type[] @params = null;

            this.argumentsSettings     = argumentsSettings;
            this.aspectWeavingSettings = aspectWeavingSettings;
            aspectArgumentType         = argumentsSettings.ArgumentType;
            weavingSettings            = aspectWeavingSettings.WeavingSettings;
            localBuilderRepository     = aspectWeavingSettings.LocalBuilderRepository;
            @params           = argumentsSettings.ArgumentType.GetGenericArguments();
            parameters        = argumentsSettings.Parameters;
            mappingParameters = @params.Skip(1).ToArray();
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedAspectWeavingSettings = aspectWeavingSettings.CloneWith(settings => {
                var localBuilderRepository = new LocalBuilderRepository();
                var aspectArgumentImplType = aspectDefinition.ToAspectArgumentImpl();

                settings.LocalBuilderRepository    = localBuilderRepository;
                settings.ByRefArgumentsStoreWeaver = new TopAspectByRefArgumentsStoreWeaver(aspectArgumentImplType, aspectDefinition.Member, localBuilderRepository);
            });

            var bindingWeaver = new IsolatedMethodInterceptionBindingWeaver(aspectExpression, aspectDefinition, clonedAspectWeavingSettings);

            return(new TopMethodInterceptionAspectWeaver(aspectDefinition, clonedAspectWeavingSettings, bindingWeaver.WeavedType));
        }
Beispiel #52
0
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedAspectWeavingSettings = aspectWeavingSettings.CloneWith(settings => {
                var localBuilderRepository = new LocalBuilderRepository();
                var aspectArgumentImplType = aspectDefinition.ToAspectArgumentImpl();

                settings.LocalBuilderRepository    = localBuilderRepository;
                settings.ByRefArgumentsStoreWeaver = new TopAspectByRefArgumentsStoreWeaver(aspectArgumentImplType, aspectDefinition.Member, localBuilderRepository);
            });

            var nestedWeaver = aspectExpression.Reduce(clonedAspectWeavingSettings);

            return(new TopOnMethodBoundaryAspectWeaver(nestedWeaver, aspectDefinition, clonedAspectWeavingSettings));
        }
Beispiel #53
0
        internal static AspectWeavingSettingsImpl CloneWith(this IAspectWeavingSettings aspectWeavingSettings, Action <AspectWeavingSettingsImpl> cloneFunc)
        {
            var clonedAspectWeavingSettings = new AspectWeavingSettingsImpl {
                WeavingSettings           = aspectWeavingSettings.WeavingSettings,
                AspectRepository          = aspectWeavingSettings.AspectRepository,
                AspectArgsMapper          = aspectWeavingSettings.AspectArgsMapper,
                LocalBuilderRepository    = aspectWeavingSettings.LocalBuilderRepository,
                ByRefArgumentsStoreWeaver = aspectWeavingSettings.ByRefArgumentsStoreWeaver
            };

            cloneFunc(clonedAspectWeavingSettings);

            return(clonedAspectWeavingSettings);
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedAspectWeavingSettings = aspectWeavingSettings.CloneWith(settings => {
                var localBuilderRepository = new LocalBuilderRepository();
                var aspectArgumentImplType = aspectDefinition.ToAspectArgumentImpl();

                settings.LocalBuilderRepository = localBuilderRepository;
                settings.ByRefArgumentsStoreWeaver = new TopAspectByRefArgumentsStoreWeaver(aspectArgumentImplType, aspectDefinition.Member, localBuilderRepository);
            });

            var bindingWeaver = new IsolatedMethodInterceptionBindingWeaver(aspectExpression, aspectDefinition, clonedAspectWeavingSettings);

            return new TopMethodInterceptionAspectWeaver(aspectDefinition, clonedAspectWeavingSettings, bindingWeaver.WeavedType);
        }
        public override IAspectWeaver Reduce(IAspectWeavingSettings aspectWeavingSettings)
        {
            var clonedAspectWeavingSettings = aspectWeavingSettings.CloneWith(settings => {
                var localBuilderRepository = new LocalBuilderRepository();
                var aspectArgumentImplType = aspectDefinition.ToAspectArgumentImpl();

                settings.LocalBuilderRepository = localBuilderRepository;
                settings.ByRefArgumentsStoreWeaver = new TopAspectByRefArgumentsStoreWeaver(aspectArgumentImplType, aspectDefinition.Member, localBuilderRepository);
            });

            var nestedWeaver = aspectExpression.Reduce(clonedAspectWeavingSettings);

            return new TopOnMethodBoundaryAspectWeaver(nestedWeaver, aspectDefinition, clonedAspectWeavingSettings);
        }
Beispiel #56
0
 internal AbstractArgumentsWeaver(TMember member, IArgumentsWeavingSettings argumentsWeavingSettings, IAspectWeavingSettings aspectWeavingSettings)
 {
     MemberInfo             = Member = member;
     ReturnType             = argumentsWeavingSettings.ReturnType;
     AspectType             = argumentsWeavingSettings.AspectType;
     Parameters             = new Type[argumentsWeavingSettings.Parameters.Length];
     LocalBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;
     ArgumentType           = argumentsWeavingSettings.ArgumentType;
     HasReturnType          = argumentsWeavingSettings.HasReturnType;
     MemberType             = argumentsWeavingSettings.MemberType;
     argumentsWeavingSettings.Parameters.CopyTo(Parameters, 0);
     this.aspectWeavingSettings = aspectWeavingSettings;
     WeavingSettings            = aspectWeavingSettings.WeavingSettings;
     BindingsDependency         = argumentsWeavingSettings.BindingsDependency;
 }
Beispiel #57
0
 internal MethodInvokerAspectWeaver(Type topAspectInScopeArgType, IMethodAspectDefinition aspectDefinition, IAspectWeavingSettings aspectWeavingSettings, IArgumentsWeavingSettings argumentsWeavingSettings)
     : base(aspectDefinition.Member, aspectWeavingSettings.WeavingSettings)
 {
     this.topAspectInScopeArgType  = topAspectInScopeArgType;
     this.argumentsWeavingSettings = argumentsWeavingSettings;
     localBuilderRepository        = aspectWeavingSettings.LocalBuilderRepository;
     byRefArgumentStoreWeaver      = aspectWeavingSettings.ByRefArgumentsStoreWeaver;
     argumentsWeaver = new MethodInvokerArgumentsWeaver(aspectDefinition.Member, topAspectInScopeArgType, aspectWeavingSettings, argumentsWeavingSettings, byRefArgumentStoreWeaver);
 }
Beispiel #58
0
 public IBindingTypeReflector Build(IAspectWeavingSettings aspectsWeavingSettings)
 {
     return(lazyBindingTypeReflector.Get(addAspectExpression, removeAspectExpression, invokeAspectExpression, aspectsWeavingSettings));
 }
 internal AbstractTopPropertyAspectArgumentsWeaver(PropertyInfo property, IArgumentsWeavingSettings argumentWeavingSettings, IAspectWeavingSettings aspectWeavingSettings)
     : base(property, argumentWeavingSettings, aspectWeavingSettings)
 {
     IsProperty         = true;
     bindingsDependency = argumentWeavingSettings.BindingsDependency;
 }
        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);
        }