You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
901 B
C#
36 lines
901 B
C#
using System.ComponentModel;
|
|
|
|
namespace TinyChat;
|
|
|
|
/// <summary>
|
|
/// Represents text-based message content.
|
|
/// </summary>
|
|
public class StringMessageContent : IChatMessageContent
|
|
{
|
|
private readonly string? _value;
|
|
|
|
/// <summary>
|
|
/// Occurs then the value of the message content changes.
|
|
/// </summary>
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="StringMessageContent"/> class.
|
|
/// </summary>
|
|
/// <param name="value">The string value of the message content.</param>
|
|
public StringMessageContent(string? value)
|
|
{
|
|
if (string.Equals(_value, value))
|
|
return;
|
|
|
|
_value = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(_value)));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public object? Content => _value;
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString() => _value?.ToString() ?? string.Empty;
|
|
}
|