Пример #1
0
        /// <summary>
        /// Executes the script
        /// </summary>
        public ScriptReturnData ExecuteScript()
        {
            srd = new ScriptReturnData();

            var sf = new ScriptFunctions(
                srd, DataPath, PluginsPath, OMOD.GetFramework(), ScriptRunnerFunctions);

            switch (type)
            {
            case ScriptType.obmmScript:
                return(OBMMScriptHandler.Execute(
                           OMOD.GetFramework(), script, DataPath, PluginsPath, ScriptRunnerFunctions));

            case ScriptType.Python:
                throw new NotImplementedException();

            case ScriptType.cSharp:
                DotNetScriptHandler.ExecuteCS(script, sf);
                break;

            case ScriptType.vb:
                DotNetScriptHandler.ExecuteVB(script, sf);
                break;
            }

            return(srd);
        }
Пример #2
0
        internal static ScriptReturnData ExecuteScript(string script, string dataPath, string pluginsPath, IScriptFunctions scriptFunctions)
        {
            Utils.Info("Starting script execution...");
            if (string.IsNullOrWhiteSpace(script))
            {
                Utils.Error("Script is empty! Returning empty ScriptReturnData");
                return(new ScriptReturnData());
            }

            ScriptType type;

            if ((byte)script[0] >= (byte)ScriptType.Count)
            {
                type = ScriptType.OBMMScript;
            }
            else
            {
                type   = (ScriptType)script[0];
                script = script.Substring(1);
            }

            Utils.Debug($"ScriptType is {type.ToString()}");

            var handler = new SharedFunctionsHandler(type, ref scriptFunctions);
            var srd     = new ScriptReturnData();
            var dotNetScriptFunctions = new Lazy <DotNetScriptFunctions>(() =>
                                                                         new DotNetScriptFunctions(srd, dataPath, pluginsPath, ref handler)).Value;

            switch (type)
            {
            case ScriptType.OBMMScript:
                return(OBMMScriptHandler.Execute(script, dataPath, pluginsPath, ref handler));

            case ScriptType.Python:     //TODO
                break;

            case ScriptType.CSharp:
                DotNetScriptHandler.ExecuteCS(script, ref dotNetScriptFunctions);
                break;

            case ScriptType.VB:
                DotNetScriptHandler.ExecuteVB(script, ref dotNetScriptFunctions);
                break;

            case ScriptType.Count:     //Impossible
                Utils.Error("Impossible switch case triggered, how dafuq did this happen?");
                break;

            default:     //Impossible
                Utils.Error("Impossible switch case triggered, how dafuq did this happen?");
                return(srd);
            }

            return(srd);
        }