Пример #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
        private void ExecuteJSScript()
        {
            FileInfo    script_file = new FileInfo (this.selected_script);
            Random      random_value = new Random ();

            // Create a new script host in which the script will run
            DvtkScriptHost  script_host =
                new DvtkScriptHost(
                /*language*/ DvtkScriptSupport.DvtkScriptLanguage.JScript,
                /*moniker*/  "dvtk://session/"+script_file.Name+random_value.Next().ToString(),
                /*importedAssemblyDir*/ Application.StartupPath);

            this.ExecuteHostScript (script_host);
        }
Пример #3
0
        private void ExecuteVBSScript()
        {
            FileInfo    script_file = new FileInfo (this.selected_script);
            Random      random_value = new Random ();

            // Create a new script host in which the script will run
            DvtkScriptHost  script_host =
                new DvtkScriptHost (
                DvtkScriptSupport.DvtkScriptLanguage.VB,
                "dvtk://session/"+script_file.Name+random_value.Next().ToString(),
                Application.StartupPath);

            this.ExecuteHostScript (script_host);
        }
Пример #4
0
        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;
        }