public void codeBlock_CallToMethod(MethodDefinition targetMethod, MethodInfo methodToCall)
        {
            var cliWorker      = targetMethod.Body.GetILProcessor();
            var lsInstructions = new List <Instruction>
            {
                cliWorker.Create(OpCodes.Call, getMethodReference(methodToCall))
            };

            CecilOpCodeUtils.addInstructionsToMethod_InsertAtEnd(targetMethod, lsInstructions);
        }
        public void codeBlock_ReadLine(MethodDefinition mdTargetMethod)
        {
            var cwCliWorker    = mdTargetMethod.Body.GetILProcessor(); // used to be called CliWorker
            var lsInstructions = new List <Instruction>
            {
                cwCliWorker.Create(OpCodes.Call,
                                   getMethodReference(typeof(Console).GetMethod("ReadLine",
                                                                                new Type[] {}))),
                cwCliWorker.Create(OpCodes.Pop)
            };

            CecilOpCodeUtils.addInstructionsToMethod_InsertAtEnd(mdTargetMethod, lsInstructions);
        }
        public void codeBlock_ConsoleWriteLine(MethodDefinition mdTargetMethod, String sText)
        {
            var cwCliWorker = mdTargetMethod.Body.GetILProcessor();

            var lsInstructions = new List <Instruction>
            {
                cwCliWorker.Create(OpCodes.Ldstr, sText),
                cwCliWorker.Create(OpCodes.Call,
                                   getMethodReference(
                                       typeof(Console).GetMethod("WriteLine",
                                                                 new[] { typeof(string) })))
            };

            CecilOpCodeUtils.addInstructionsToMethod_InsertAtEnd(mdTargetMethod, lsInstructions);
        }