示例#1
0
        // RunCode_ExecuteCode must throw an exception if he can't execute run method
        // if no error thrown RunCode_ExecuteCode must call RunCode_EndRun()
        private void RunCode_ExecuteCode(Assembly assembly, GenerateCSharpCodeResult codeResult, CompilerProject compilerProject, Compiler compiler, bool useNewThread)
        {
            _runCode                    = new RunCode();
            _runCode.RunAssembly        = assembly;
            _runCode.CompilerAssemblies = compiler.Assemblies;
            //_runCode.RunClassName = codeResult.GetFullClassName();
            //_runCode.RunMethodName = codeResult.RunMethodName;
            _runCode.RunMethodName  = codeResult.GetFullRunMethodName();
            _runCode.InitMethodName = compilerProject.GetInitMethod();  // "Init"
            _runCode.EndMethodName  = compilerProject.GetEndMethod();   // "End"
            _runCode.EndRun        += RunCode_EndRun;

            _executionAborted = false;

            _runCode.Run(useNewThread);
            //_runCodeThread = runCode.RunThread;
        }
示例#2
0
        // RunCode_ExecuteCode must throw an exception if he can't execute run method
        // if no error thrown RunCode_ExecuteCode must call RunCode_EndRun()
        //private void RunCode_ExecuteCode(Assembly assembly, GenerateCSharpCodeResult codeResult, CompilerProject compilerProject, Compiler compiler, bool useNewThread)
        private void RunCode_ExecuteCode(Assembly assembly, GenerateCSharpCodeResult codeResult, CompilerProjectReader compilerProject, ProjectCompiler compiler, bool runOnMainThread, bool callInit)
        {
            RunCode runCode = new RunCode(++_runCodeId);
            runCode.RunAssembly = assembly;
            //runCode.CompilerAssemblies = compiler.Assemblies;
            runCode.RunMethodName = codeResult.GetFullRunMethodName();
            runCode.EndRun += error => RunCode_EndRun(runCode, error);

            //if (forceCallInit)
            //    _runSourceInitEndMethods.CallInit = true;

            _executionAborted = false;

            foreach (CompilerAssembly compilerAssembly in compiler.Assemblies.Values)
            {
                //WriteLine(2, "  Assembly              \"{0}\" resolve {1}", assembly.File, assembly.Resolve);
                if (compilerAssembly.Resolve)
                    AssemblyResolve.Add(compilerAssembly.File, compilerAssembly.ResolveName);
            }

            //_runSourceInitEndMethods.CallInit = callInit;
            //if (callInit)
            //_runSourceInitEndMethods.CallInitMethods(compilerProject.GetInitMethods(), compilerProject.GetEndMethods(), callInit, methodName => runCode.GetMethod(methodName));
            _runSourceInitEndMethods.CallInitMethods(compilerProject.GetInitMethods(), compilerProject.GetEndMethods(), callInit, methodName => zReflection.GetMethod(methodName, assembly, ErrorOptions.TraceWarning));

            // add runCode to _runCodes after call init, if call init fail runCode is not in _runCodes
            if (!_runCodes.TryAdd(runCode.Id, runCode))
                throw new PBException("unable to add RunCode id {0} to ConcurrentDictionary", runCode.Id);

            runCode.Run(runOnMainThread);

            // problem with AssemblyResolve.Clear() end method may need to resolve assembly
            //AssemblyResolve.Clear();
        }
示例#3
0
        // RunCode_ExecuteCode must throw an exception if he can't execute run method
        // if no error thrown RunCode_ExecuteCode must call RunCode_EndRun()
        private void RunCode_ExecuteCode(Assembly assembly, GenerateCSharpCodeResult codeResult, CompilerProject compilerProject, Compiler compiler, bool useNewThread)
        {
            _runCode = new RunCode();
            _runCode.RunAssembly = assembly;
            _runCode.CompilerAssemblies = compiler.Assemblies;
            //_runCode.RunClassName = codeResult.GetFullClassName();
            //_runCode.RunMethodName = codeResult.RunMethodName;
            _runCode.RunMethodName = codeResult.GetFullRunMethodName();
            _runCode.InitMethodName = compilerProject.GetInitMethod();  // "Init"
            _runCode.EndMethodName = compilerProject.GetEndMethod();    // "End"
            _runCode.EndRun += RunCode_EndRun;

            _executionAborted = false;

            _runCode.Run(useNewThread);
            //_runCodeThread = runCode.RunThread;
        }