예제 #1
0
        public void Replace(IMethodContext context, ModuleDefinition targetModule)
        {
            var currentMethod = context.CurrentMethod;
            var currentArguments = context.CurrentArguments;
            var currentArgument = context.CurrentArgument;
            var pushMethod = targetModule.ImportMethod<Stack<object>>("Push");
            var worker = context.CilWorker;

            var methodMap = _context.MethodMap;
            var targetDependency = _context.TargetDependency;
            var interfaceType = _context.InterfaceType;

            var adapterConstructor = _adapterBuilder.CreateAdapterConstructor(methodMap);
            foreach (ParameterReference param in currentMethod.Parameters)
            {
                var arguments = new ParameterContext(worker,
                interfaceType,
                pushMethod,
                currentArguments,
                currentArgument,
                targetDependency, adapterConstructor, param);

                // Save the current argument
                _pushParameter.Adapt(arguments);
            }
        }
예제 #2
0
        public void Replace(IMethodContext context, ModuleDefinition targetModule)
        {
            var currentMethod    = context.CurrentMethod;
            var currentArguments = context.CurrentArguments;
            var currentArgument  = context.CurrentArgument;
            var pushMethod       = targetModule.ImportMethod <Stack <object> >("Push");
            var worker           = context.CilWorker;

            var methodMap        = _context.MethodMap;
            var targetDependency = _context.TargetDependency;
            var interfaceType    = _context.InterfaceType;

            var adapterConstructor = _adapterBuilder.CreateAdapterConstructor(methodMap);

            foreach (ParameterReference param in currentMethod.Parameters)
            {
                var arguments = new ParameterContext(worker,
                                                     interfaceType,
                                                     pushMethod,
                                                     currentArguments,
                                                     currentArgument,
                                                     targetDependency, adapterConstructor, param);

                // Save the current argument
                _pushParameter.Adapt(arguments);
            }
        }