/// <summary> /// Renames a macro /// </summary> /// <param name="declaration">The macro</param> /// <param name="newname">The macro's new name</param> public void RenameFile(FileDeclaration d, string newname) { d.Save(); d.Rename(newname); d.Save(); Events.InvokeEvent("OnMacroRenamed", d); }
/// <summary> /// Execute the macro using the source saved in macro /// </summary> /// <param name="async">Bool identifying if the macro should be execute asynchronously or not (synchronous)</param> /// <param name="runtime">Runtime tag identifying which execution engine to use, if empty, a default will be chosen</param> public async Task <bool> TryExecuteFile(FileDeclaration d, bool async, string runtime = "") { d.Save(); if (string.IsNullOrEmpty(runtime)) { runtime = GetDefaultRuntime(); } IExecutionEngine engine = GetExecutionEngine(runtime); if (engine == null) { engine = GetExecutionEngine(GetDefaultRuntime()); } if (engine == null) { return(false); } return(await engine.ExecuteMacro(d.Content, async, d.Info != null?d.Info.Directory.FullName : "")); }