Inheritance: ILocalBuilderRepository
        public override void Weave(ILGenerator ilGenerator)
        {
            var argsLocalBuilder     = LocalBuilderRepository.Get(previousAspectArgType);
            var contractFieldBuilder = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType);
            var methodImplParameters = WeavingSettings.MethodInfoImpl.GetParameters();

            ilGenerator.EmitLoadArg(0);
            ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder);

            methodImplParameters.ForEach(param => {
                int argPosition = param.Position + 1;

                if (byRefArgumentStoreWeaver.Contains(argPosition))
                {
                    ilGenerator.EmitLoadArg(argPosition);
                }
                else
                {
                    var property = previousAspectArgType.GetProperty("Arg{0}".Fmt(argPosition));

                    ilGenerator.EmitLoadLocal(argsLocalBuilder);
                    ilGenerator.Emit(OpCodes.Callvirt, property.GetGetMethod());
                }
            });
        }
        public override void Weave(ILGenerator ilGenerator)
        {
            LocalBuilder argsImplLocalBuilder = null;
            var          ctorInterceptionArgs = ArgumentType.GetConstructors()[0];
            var          aspectArgsType       = Member.ToAspectArgumentContract();
            var          methodProperty       = aspectArgsType.GetProperty("Method");

            argsImplLocalBuilder = LocalBuilderRepository.GetOrDeclare(ArgumentType, () => {
                return(ilGenerator.DeclareLocal(ArgumentType));
            });

            ilGenerator.EmitLoadArg(1);
            ilGenerator.Emit(OpCodes.Ldind_Ref);
            WeaveAspectArg(ilGenerator);
            ilGenerator.Emit(OpCodes.Callvirt, methodProperty.GetGetMethod());
            ilGenerator.Emit(OpCodes.Ldsfld, bindingsDependency);

            Parameters.ForEach(1, (parameter, i) => {
                var property = aspectArgsType.GetProperty("Arg{0}".Fmt(i));

                WeaveAspectArg(ilGenerator);
                ilGenerator.Emit(OpCodes.Callvirt, property.GetGetMethod());
            });

            ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs);
            ilGenerator.EmitStoreLocal(argsImplLocalBuilder);
        }
        public override LocalBuilder BuildArguments(ILGenerator ilGenerator)
        {
            LocalBuilder           methodLocalBuilder    = null;
            FieldBuilder           contractFieldBuilder  = null;
            LocalBuilder           aspectArgLocalBuilder = null;
            AspectArgsMethodWeaver methodWeaver          = null;
            ConstructorInfo        ctorInterceptionArgs  = null;

            methodLocalBuilder = LocalBuilderRepository.Declare(() => {
                return(ilGenerator.DeclareLocal(typeof(MethodInfo)));
            });

            aspectArgLocalBuilder = ilGenerator.DeclareLocal(ArgumentType);
            contractFieldBuilder  = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType);
            methodWeaver          = new AspectArgsMethodWeaver(Member, methodLocalBuilder, Parameters, aspectWeavingSettings);
            methodWeaver.Weave(ilGenerator);
            ilGenerator.EmitLoadArg(0);
            ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder);
            ilGenerator.EmitLoadLocal(methodLocalBuilder);
            ctorInterceptionArgs = ArgumentType.GetConstructors()[0];

            Parameters.ForEach(1, (parameter, i) => {
                ilGenerator.EmitLoadArg(i);

                if (parameter.IsByRef)
                {
                    ilGenerator.Emit(OpCodes.Ldind_I4);
                }
            });

            ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs);
            ilGenerator.EmitStoreLocal(aspectArgLocalBuilder);

            return(aspectArgLocalBuilder);
        }
        public override LocalBuilder BuildArguments(ILGenerator ilGenerator)
        {
            LocalBuilder    propertyLocalBuilder          = null;
            FieldBuilder    contractFieldBuilder          = null;
            LocalBuilder    aspectArgLocalBuilder         = null;
            ConstructorInfo ctorInterceptionArgs          = null;
            AbstractAspectPropertyArgsWeaver methodWeaver = null;

            propertyLocalBuilder = LocalBuilderRepository.Declare(() => {
                return(ilGenerator.DeclareLocal(typeof(PropertyInfo)));
            });

            ctorInterceptionArgs  = ArgumentType.GetConstructors()[0];
            aspectArgLocalBuilder = ilGenerator.DeclareLocal(ArgumentType);
            contractFieldBuilder  = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType);
            methodWeaver          = new AspectArgsSetPropertyWeaver(Member, propertyLocalBuilder, aspectWeavingSettings);
            methodWeaver.Weave(ilGenerator);
            ilGenerator.EmitLoadArg(0);
            ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder);
            ilGenerator.EmitLoadLocal(propertyLocalBuilder);
            ilGenerator.Emit(OpCodes.Ldsfld, BindingsDependency);
            ilGenerator.EmitLoadArg(1);
            ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs);
            ilGenerator.EmitStoreLocal(aspectArgLocalBuilder);

            return(aspectArgLocalBuilder);
        }
Esempio n. 5
0
        public override void Weave(ILGenerator ilGenerator)
        {
            FieldBuilder contractFieldBuilder = null;
            var          declaredLocalBuilder = ilGenerator.DeclareLocal(ArgumentType);
            var          ctorInterceptionArgs = ArgumentType.GetConstructors()[0];
            var          argsLocalBuilder     = LocalBuilderRepository.Get(previousAspectArgType);
            var          methodPropoertyInfo  = previousAspectArgType.GetProperty("Method");

            LocalBuilderRepository.Add(declaredLocalBuilder);
            contractFieldBuilder = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType);
            ilGenerator.EmitLoadArg(0);
            ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder);
            ilGenerator.EmitLoadLocal(argsLocalBuilder);
            ilGenerator.Emit(OpCodes.Callvirt, methodPropoertyInfo.GetGetMethod());
            ilGenerator.Emit(OpCodes.Ldsfld, BindingsDependency);

            Parameters.ForEach(1, (parameter, i) => {
                var property = previousAspectArgType.GetProperty("Arg{0}".Fmt(i));

                ilGenerator.EmitLoadLocal(argsLocalBuilder);
                ilGenerator.Emit(OpCodes.Callvirt, property.GetGetMethod());
            });

            ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs);
            ilGenerator.EmitStoreLocal(declaredLocalBuilder);
        }
Esempio n. 6
0
        public override void Weave(ILGenerator ilGenerator)
        {
            var argsLocalBuilder     = LocalBuilderRepository.Get(previousAspectArgType);
            var methodImplParameters = Member.GetParameters();

            ilGenerator.EmitLoadArg(1);
            ilGenerator.Emit(OpCodes.Ldind_Ref);

            methodImplParameters.ForEach(param => {
                int argPosition = param.Position + 1;

                if (byRefArgumentStoreWeaver.Contains(argPosition))
                {
                    byRefArgumentStoreWeaver.EmitLoadLocalAddress(ilGenerator, argPosition);
                }
                else
                {
                    var property = previousAspectArgType.GetProperty("Arg{0}".Fmt(argPosition));

                    ilGenerator.EmitLoadLocal(argsLocalBuilder);
                    ilGenerator.Emit(OpCodes.Callvirt, property.GetGetMethod());
                }
            });
        }
        public override void Weave(ILGenerator ilGenerator)
        {
            var localBuilder = BuildArguments(ilGenerator);

            LocalBuilderRepository.Add(localBuilder);
        }