• SysCompilerTarget compiling X++ code without showing the compilation window


    PS:http://kashperuk.blogspot.com/2009/11/syscompilertarget-compiling-x-code.html

    I have been posed with a question about how to avoid showing the compilation window during compilation of some X++ code (When doing compilation from code, naturally).
    So I decided to post a possible solution for this question, re-using one of my previous posts about ClassBuild class.
    Basically, AOTcompile method on TreeNode class supports an optional flag, controlling the compilation output:
    An integer that indicates whether output should be sent to the message box. If the value 1 is passed, no output is sent to the message box. The default value is 0. This parameter is optional.
    So all we need to do now is change the compilation output target to Message Window. Looking at the SysCompilerSetup form code, it's rather easy to come up with the following code:

    static void Jimmy_CompilerTargetShowing(Args _args)
    {
        ClassBuild          classBuild;
        DictClass           dictClass;
        SysCompilerTarget   targetOrig;
    ;
        //1)Setting Compilation Target =0 Message Window 1 = Compiler Dialog
        targetOrig = SysUserInfo::compilerTarget(SysCompilerTarget::MessageWindow);
        SysUserInfo::compilerTarget(SysCompilerTarget::CompilerDialog); // set up Compilation Target
        SysCompilerOutput::setCompilerTarget(SysCompilerTarget::MessageWindow);
        SysCompilerOutput::updateParm();
    
        //2)Building the class with 1 method
        classBuild = new ClassBuild("QVS_class02", true);
        classBuild.addMethod("fiest", 'void fiest()\n{\n}');
        classBuild.addSourceToMethod("test", @";\n    info('We created a Class and can call its methods');");
        // The actual compilation. Note the _flag argument == 1
        classBuild.classNode().AOTcompile(1);
        // Call the class method to show that we are done and the code is compiled
        dictClass = new DictClass(className2Id(classBuild.name()));
        dictClass.callObject("fiest",dictClass.makeObject());
    
       
        //3)Restoring Compilation Target to its original value
        SysUserInfo::compilerTarget(targetOrig);
        SysCompilerOutput::setCompilerTarget(targetOrig);
        SysCompilerOutput::updateParm();
    }
    
  • 相关阅读:
    手写简易SpringMVC框架,包含@PathVariable
    高并发下,如何保证接口的幂等性?
    JAVA判断奇偶数
    多线程ForkJoin-分治思想
    websocket简单使用
    Git使用教程:最详细、最傻瓜、最浅显、真正手把手教!(转载学习)
    linux配置java环境变量(详细)
    java缓存技术的介绍(转载)
    java 多态性详解及常见面试题
    oracle数据库基础知识总结(一)
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1894662.html
Copyright © 2020-2023  润新知