예제 #1
0
        public List <CompilationErrorTS> Compile(bool inMemory)
        {
            SystemEventLogLogic.Log("DynamicController.Compile");
            var compileResult = new List <DynamicLogic.CompilationResult>();

            if (!inMemory)
            {
                DynamicLogic.CleanCodeGenFolder();
            }

            Dictionary <string, CodeFile> codeFiles = DynamicLogic.GetCodeFilesDictionary();

            compileResult.Add(DynamicLogic.Compile(codeFiles, inMemory: inMemory, assemblyName: DynamicCode.CodeGenAssembly, needsCodeGenAssembly: false));

            if (DynamicApiLogic.IsStarted)
            {
                Dictionary <string, CodeFile> apiFiles = DynamicApiLogic.GetCodeFiles().ToDictionaryEx(a => a.FileName, "CodeGenController C# code file");
                compileResult.Add(DynamicLogic.Compile(apiFiles, inMemory: inMemory, assemblyName: DynamicCode.CodeGenControllerAssembly, needsCodeGenAssembly: true));
                codeFiles.AddRange(apiFiles);
            }

            return((from cr in compileResult
                    from ce in cr.Errors
                    let fileName = Path.GetFileName(ce.FileName)
                                   select(new CompilationErrorTS
            {
                fileName = fileName,
                column = ce.Column,
                line = ce.Line,
                errorNumber = ce.ErrorNumber,
                errorText = ce.ErrorText,
                fileContent = codeFiles.GetOrThrow(fileName).FileContent
            })).ToList());
        }
예제 #2
0
        public List <CompilationErrorTS> Compile()
        {
            SystemEventLogLogic.Log("DynamicController.Compile");
            Dictionary <string, CodeFile> codeFiles = DynamicLogic.GetCodeFilesDictionary();
            var result = DynamicLogic.Compile(codeFiles, inMemory: true);

            return((from ce in result.Errors.Cast <CompilerError>()
                    let fileName = Path.GetFileName(ce.FileName)
                                   select(new CompilationErrorTS
            {
                fileName = fileName,
                column = ce.Column,
                line = ce.Line,
                errorNumber = ce.ErrorNumber,
                errorText = ce.ErrorText,
                fileContent = codeFiles.GetOrThrow(fileName).FileContent
            })).ToList());
        }