コード例 #1
0
        public void ExecuteVBScript(System.String scriptFile, System.String[] args)
        {
            Random randomValue = new Random();

            // Create a new script host in which the script will run
            DvtkScriptHost scriptHost = new DvtkScriptHost(
                DvtkScriptSupport.DvtkScriptLanguage.VB,
                "dvtk://session/" + randomValue.Next().ToString(),
                System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase);

            // Create the event hanlder for handling the compiler error messages
            DvtkScriptSupport.CompilerErrorEventHandler compilerEventHandler = new CompilerErrorEventHandler(scriptHostCompilerErrorEvent);
            scriptHost.CompilerErrorEvent += compilerEventHandler;

            // Set the current active session in the script host
            scriptHost.Session = new Dvtk.Sessions.ScriptSession();

            // Assign the script content to the script host.
            scriptHost.SourceCode = ScriptContent(scriptFile);

            // Compile the script
            if (scriptHost.Compile())
            {
                // Run the script
                scriptHost.Invoke("DvtkIheScript", "DvtIheMain", args);
            }

            // Remove the event hanlder for handling the compiler error messages
            scriptHost.CompilerErrorEvent -= compilerEventHandler;
        }
コード例 #2
0
        public void ExecuteVBScript(System.String scriptFile, System.String[] args)
        {
            Random randomValue = new Random();

            // Create a new script host in which the script will run
            DvtkScriptHost scriptHost = new DvtkScriptHost(
                                    DvtkScriptSupport.DvtkScriptLanguage.VB,
                                    "dvtk://session/"+randomValue.Next().ToString(),
                                    System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase);

            // Create the event hanlder for handling the compiler error messages
            DvtkScriptSupport.CompilerErrorEventHandler compilerEventHandler = new CompilerErrorEventHandler(scriptHostCompilerErrorEvent);
            scriptHost.CompilerErrorEvent += compilerEventHandler;

            // Set the current active session in the script host
            scriptHost.Session = new Dvtk.Sessions.ScriptSession();

            // Assign the script content to the script host.
            scriptHost.SourceCode = ScriptContent(scriptFile);

            // Compile the script
            if (scriptHost.Compile())
            {
                // Run the script
                scriptHost.Invoke("DvtkIheScript", "DvtIheMain", args);
            }

            // Remove the event hanlder for handling the compiler error messages
            scriptHost.CompilerErrorEvent -= compilerEventHandler;
        }
コード例 #3
0
        /// <summary>
        /// Raises the <see cref="E:CompilerError" /> event.
        /// </summary>
        /// <param name="e">The <see cref="CompilerErrorEventArgs"/> instance containing the event data.</param>
        protected virtual void OnCompilerError(CompilerErrorEventArgs e)
        {
            CompilerErrorEventHandler compilerError = this.CompilerError;

            if (this.CompilerError != null)
            {
                this.CompilerError(this, e);
            }
        }
コード例 #4
0
ファイル: ScriptFile.cs プロジェクト: sharpsteve/papyrus-lang
        private T UseCompiler <T>(Func <ScriptCompiler, Dictionary <string, ScriptComplexType>, T> action, CompilerErrorEventHandler errorHandler = null)
        {
            var compiler = _compiler.Value;

            lock (compiler)
            {
                try
                {
                    if (errorHandler != null)
                    {
                        compiler.CompilerErrorHandler += errorHandler;
                    }

                    return(action(compiler, _program.TypeChecker.CompilerTypeTable.Types));
                }
                finally
                {
                    if (errorHandler != null)
                    {
                        compiler.CompilerErrorHandler -= errorHandler;
                    }
                }
            }
        }
コード例 #5
0
ファイル: ProjectForm.cs プロジェクト: ewcasas/DVTK
        private void ExecuteHostScript(DvtkScriptHost script_host)
        {
            DvtkScriptSupport.CompilerErrorEventHandler     compiler_event_handler;

            // Create the event hanlder for handling the compiler error messages
            compiler_event_handler = new CompilerErrorEventHandler(script_host_CompilerErrorEvent);
            script_host.CompilerErrorEvent += compiler_event_handler;

            // Set the current active session in the script host
            script_host.Session = (Dvtk.Sessions.ScriptSession)this.selected_session;

            // Assign the script content to the script host.
            script_host.SourceCode = this.ScriptContent (this.selected_script);

            // Compile the script
            if (script_host.Compile ())
            {
                // Run the script
                script_host.Invoke ("DvtkScript", "Main", null);
            }

            // Notify the root process that the script has finished executing
            this.RunningProcessEvent (this, null);

            // Remove the event hanlder for handling the compiler error messages
            script_host.CompilerErrorEvent -= compiler_event_handler;
        }