rabidus-test/Assets/Plugins/QFSW/Quantum Console/Source/Scripts/Actions/Value.cs

31 lines
948 B
C#
Raw Normal View History

2023-08-22 15:41:12 +03:00
namespace QFSW.QC.Actions
{
/// <summary>
/// Serializes and logs a value to the console.
/// </summary>
public class Value : ICommandAction
{
private readonly object _value;
private readonly bool _newline;
public bool IsFinished => true;
public bool StartsIdle => false;
/// <param name="value">The value to log to the console.</param>
/// <param name="newline">If the value should be logged on a new line.</param>
public Value(object value, bool newline = true)
{
_value = value;
_newline = newline;
}
public void Start(ActionContext context) { }
public void Finalize(ActionContext context)
{
QuantumConsole console = context.Console;
string serialized = _value as string ?? console.Serialize(_value);
console.LogToConsole(serialized, _newline);
}
}
}