namespace RhythmBase.Components.RichText
{
///
/// Represents a list of dialogue lines.
///
public class RDDialogueExchange : List
{
///
/// Serializes the dialogue list to a string.
///
/// A string representation of the dialogue list.
public string Serialize() => string.Join('\n', this.Select(i => i.Serialize()));
///
/// Deserializes a string into a instance.
///
/// The string to deserialize.
/// A new containing the deserialized dialogue lines.
public static RDDialogueExchange Deserialize(string text) => [.. text.Split("\r\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(RDDialogueBlock.Deserialize)];
///
/// Deserializes a string into a instance, using a lookup of valid expressions.
///
/// The string to deserialize.
/// A lookup of valid expressions for each character.
/// A new containing the deserialized dialogue lines.
/// Thrown when the input string is null.
/// Thrown when the input string has an invalid format.
public static RDDialogueExchange Deserialize(string text, ILookup expressions) => [.. text.Split("\r\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(i => RDDialogueBlock.Deserialize(i, expressions))];
///
public override string ToString() => string.Join('\n', this.Select(i => i.ToString()));
}
}