/// <summary> /// Interprets the scripting status. /// </summary> /// <param name="scriptingStatus">The scripting status.</param> /// <returns></returns> public Message InterpretScriptingStatus(ScriptingStatus scriptingStatus) { ScriptExecuteInfo scriptExecuteInfo = scriptingStatus.AditionalData as ScriptExecuteInfo; return(new Message { Color = ConsoleOutputColor.Blue, Text = $"[{ scriptExecuteInfo.FileName }]: Script finished executing..." }); }
/// <summary> /// Interprets the scripting status. /// </summary> /// <param name="scriptingStatus">The scripting status.</param> /// <returns></returns> public Message InterpretScriptingStatus(ScriptingStatus scriptingStatus) { ScriptExecuteInfo scriptExecuteInfo = scriptingStatus.AditionalData as ScriptExecuteInfo; return(new Message { Color = ConsoleOutputColor.Green, Text = $"[{ scriptExecuteInfo.FileName }]: SUCCESS" }); }
/// <summary> /// Interprets the scripting status. /// </summary> /// <param name="scriptingStatus">The scripting status.</param> /// <returns></returns> public Message InterpretScriptingStatus(ScriptingStatus scriptingStatus) { ScriptExecuteInfo scriptExecuteInfo = scriptingStatus.AditionalData as ScriptExecuteInfo; StringBuilder interpretedStatusMessage = new StringBuilder($"[{ scriptExecuteInfo.FileName }]: FAIL"); interpretedStatusMessage.AppendLine(); interpretedStatusMessage.Append(scriptExecuteInfo.ThrownException.Message); return(new Message { Color = ConsoleOutputColor.Red, Text = interpretedStatusMessage.ToString() }); }
/// <summary> /// Executes the scripts asynchronously. /// </summary> /// <param name="scriptFileDiscoveryInfo">The script files discovery information.</param> /// <returns></returns> public async Task ExecuteScriptAsync(FileDiscoveryInfo scriptFileDiscoveryInfo) { Script script = await this.scriptLoaderService.LoadScript(scriptFileDiscoveryInfo.FullFileName).ConfigureAwait(false); this.NotifyObservers(ScriptingStatusDescription.BeginScriptExecute, script.GetScriptExecuteInfo()); try { await CSharpScript.EvaluateAsync(script.Content).ConfigureAwait(false); this.NotifyObservers(ScriptingStatusDescription.SuccessScriptExecute, script.GetScriptExecuteInfo()); } catch (Exception ex) { ScriptExecuteInfo otherErrorScriptExecuteInfo = script.GetScriptExecuteInfo(); otherErrorScriptExecuteInfo.ThrownException = ex; this.NotifyObservers(ScriptingStatusDescription.FailScriptExecute, otherErrorScriptExecuteInfo); } this.NotifyObservers(ScriptingStatusDescription.FinalizeScriptExecute, script.GetScriptExecuteInfo()); }