Exemple #1
0
        public PushRuntime(IScriptRuntime runtime)
        {
            EnsureRuntimeHandler();

            ms_runtimeHandler.PushRuntime(runtime);

            m_runtime = runtime;
        }
Exemple #2
0
        public PushRuntime(IScriptRuntime runtime, IntPtr comRuntime = default)
        {
#if !IS_FXSERVER || OS_WIN
            ms_pushMethod.method(ms_runtimeHandlerIface, comRuntime);

            m_runtime = comRuntime;
#else
            ms_runtimeHandler.PushRuntime(runtime);

            m_runtime       = IntPtr.Zero;
            m_actualRuntime = runtime;
#endif
        }
Exemple #3
0
        public PushRuntime(IScriptRuntime runtime)
        {
            EnsureRuntimeHandler();

#if !IS_FXSERVER
            var comRuntime = Marshal.GetComInterfaceForObject(runtime, typeof(IScriptRuntime));
            ms_pushMethod.method(ms_runtimeHandlerIface, comRuntime);

            m_runtime = comRuntime;
#else
            ms_runtimeHandler.PushRuntime(runtime);

            m_actualRuntime = runtime;
#endif
        }
Exemple #4
0
        internal void ExecuteScriptAction(ScriptLanguage language, string script, Game game)
        {
            if (language == ScriptLanguage.PowerShell && !Scripting.PowerShell.PowerShellRuntime.IsInstalled)
            {
                throw new Exception(resources.GetString("LOCErrorPowerShellNotInstalled"));
            }

            logger.Info($"Executing script action in {language} runtime.");
            IScriptRuntime runtime = null;

            switch (language)
            {
            case ScriptLanguage.PowerShell:
                runtime = new Scripting.PowerShell.PowerShellRuntime();
                break;

            case ScriptLanguage.IronPython:
                runtime = new Scripting.IronPython.IronPythonRuntime();
                break;

            case ScriptLanguage.Batch:
                runtime = new Scripting.Batch.BatchRuntime();
                break;
            }

            using (runtime)
            {
                var dir = game.ExpandVariables(game.InstallDirectory, true);
                if (!dir.IsNullOrEmpty() && Directory.Exists(dir))
                {
                    runtime.Execute(script, dir);
                }
                else
                {
                    runtime.Execute(script);
                }
            }
        }