Пример #1
0
        //public StandAloneExe(MethodInfo targetMethodInfo)
        //{
        //
        //       }
        public static string createMainPointingToMethodInfo(MethodInfo targetMethodInfo)
        {
            var exeName = targetMethodInfo.Name;

            var cecilAssemblyBuilder = new CecilAssemblyBuilder(exeName, AssemblyKind.Console);
            TypeDefinition tdType = cecilAssemblyBuilder.addType("O2StandAloneExe", "Program");
            MethodDefinition mdMain = cecilAssemblyBuilder.addMainMethod(tdType);
            cecilAssemblyBuilder.codeBlock_CallToMethod(mdMain, targetMethodInfo);
            var exeFileCreated = cecilAssemblyBuilder.Save(DI.config.O2TempDir);

            DI.log.info("Exe file created: {0}", exeFileCreated);
            return exeFileCreated;
        }
        //public StandAloneExe(MethodInfo targetMethodInfo)
        //{
//
//       }
        public static string createMainPointingToMethodInfo(MethodInfo targetMethodInfo)
        {
            var exeName = targetMethodInfo.Name;

            var              cecilAssemblyBuilder = new CecilAssemblyBuilder(exeName, ModuleKind.Console);
            TypeDefinition   tdType = cecilAssemblyBuilder.addType("O2StandAloneExe", "Program");
            MethodDefinition mdMain = cecilAssemblyBuilder.addMainMethod(tdType);

            cecilAssemblyBuilder.codeBlock_CallToMethod(mdMain, targetMethodInfo);
            var exeFileCreated = cecilAssemblyBuilder.Save(PublicDI.config.O2TempDir);

            PublicDI.log.info("Exe file created: {0}", exeFileCreated);
            return(exeFileCreated);
        }
 public CreateTestExe createBasicHelloWorldExe(bool bWithPressEnter)
 {
     cecilAssemblyBuilder = new CecilAssemblyBuilder(exeName, ModuleKind.Console);
     TypeDefinition tdType = cecilAssemblyBuilder.addType("BasicTest", "Program");
     MethodDefinition mdMain = cecilAssemblyBuilder.addMainMethod(tdType);
     cecilAssemblyBuilder.codeBlock_ConsoleWriteLine(mdMain,
                                                     String.Format(
                                                         "Hello World " + Environment.NewLine +
                                                         Environment.NewLine +
                                                         "(Created at {0})" + Environment.NewLine +
                                                         Environment.NewLine +
                                                         "(by {1})", DateTime.Now, Environment.UserName));
     if (bWithPressEnter)
         cecilAssemblyBuilder.codeBlock_PressEnter(mdMain);
     return this;
 }
Пример #4
0
        public CreateTestExe createBasicHelloWorldExe(bool bWithPressEnter)
        {
            cecilAssemblyBuilder = new CecilAssemblyBuilder(exeName, ModuleKind.Console);
            TypeDefinition   tdType = cecilAssemblyBuilder.addType("BasicTest", "Program");
            MethodDefinition mdMain = cecilAssemblyBuilder.addMainMethod(tdType);

            cecilAssemblyBuilder.codeBlock_ConsoleWriteLine(mdMain,
                                                            String.Format(
                                                                "Hello World " + Environment.NewLine +
                                                                Environment.NewLine +
                                                                "(Created at {0})" + Environment.NewLine +
                                                                Environment.NewLine +
                                                                "(by {1})", DateTime.Now, Environment.UserName));
            if (bWithPressEnter)
            {
                cecilAssemblyBuilder.codeBlock_PressEnter(mdMain);
            }
            return(this);
        }