public void InvokeEndFileEventMode(EndFileEventMode arg) { Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { arg.ToString() }); }); }
public static void LoadScripts() { if (Directory.Exists(Application.StartupPath + "\\Scripts")) { string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts"); foreach (string scriptPath in startupScripts) { if (scriptPath.EndsWith(".lua") || scriptPath.EndsWith(".js")) { commandv("load-script", $"{scriptPath}"); } } foreach (string scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } } foreach (string scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } } if (Directory.Exists(ConfigFolder + "Scripts")) { foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "Scripts")) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } else if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } } }
public static void LoadScripts() { string[] jsLua = { ".lua", ".js" }; string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts"); foreach (var scriptPath in startupScripts) { if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower())) { commandv("load-script", $"{scriptPath}"); } } foreach (var scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } } foreach (var scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } if (Directory.Exists(ConfFolder + "Scripts")) { foreach (var scriptPath in Directory.GetFiles(ConfFolder + "Scripts")) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } else if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } } }
public static void Init(string filePath) { foreach (var eventInfo in typeof(mp).GetEvents()) { if (eventInfo.Name.ToLower() == Path.GetFileNameWithoutExtension(filePath).ToLower().Replace("-", "")) { PowerShellEventObject eventObject = new PowerShellEventObject(); MethodInfo mi; eventObject.FilePath = filePath; if (eventInfo.EventHandlerType == typeof(Action)) { mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke)); } else if (eventInfo.EventHandlerType == typeof(Action <EndFileEventMode>)) { mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeEndFileEventMode)); } else if (eventInfo.EventHandlerType == typeof(Action <string[]>)) { mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings)); } else { throw new Exception(); } eventObject.EventInfo = eventInfo; Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventObject, mi); eventObject.Delegate = handler; eventInfo.AddEventHandler(eventObject, handler); return; } } Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(filePath), new string[] {}); }); }
public void InvokeStrings(string[] args) { Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), args)); }
public void Invoke() => Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), null); });
public void Invoke() { Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { }); }); }
public void InvokeStrings(string[] args) => PowerShellScript.Execute(Filepath, args);
public void InvokeEndFile(EndFileEventMode arg) => PowerShellScript.Execute(Filepath, arg.ToString());
public void Invoke() => PowerShellScript.Execute(Filepath);