58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using System;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
[JsonObject(MemberSerialization.OptIn)]
|
|
public class AiConversationMessageVM : AbstractDCMapperVM<AiConversationMessageDC>
|
|
{
|
|
private string _Message;
|
|
|
|
public AiConversationMessageVM(AiConversationMessageDC dc) : base(dc, dc.Oid is null)
|
|
{
|
|
|
|
}
|
|
|
|
public string Json
|
|
{
|
|
get => JsonConvert.SerializeObject(this, Formatting.Indented);
|
|
}
|
|
|
|
[JsonProperty(Order = 1)]
|
|
public string Message
|
|
{
|
|
get { return _Message; }
|
|
set
|
|
{
|
|
if (!AreDifferent(Message, value))
|
|
return;
|
|
|
|
_Message = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Message, value), nameof(Message));
|
|
FirePropertyChanged(nameof(Message));
|
|
}
|
|
}
|
|
|
|
[JsonProperty(Order = 2)]
|
|
public string Role => DataContract.Role.ToString();
|
|
|
|
[JsonProperty(Order = 3)]
|
|
public string Time => DataContract.Created.ToString();
|
|
|
|
protected override void InitByDataContract(AiConversationMessageDC pDataContract)
|
|
{
|
|
_Message = pDataContract.Message;
|
|
}
|
|
|
|
protected override AiConversationMessageDC MapToDataContract(AiConversationMessageDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.Message = _Message;
|
|
|
|
return pDataContract;
|
|
}
|
|
}
|
|
}
|