forked from aly/qstbak
qstcompanion v1.0.6
This commit is contained in:
parent
5e1e1decc5
commit
ada27cf05b
30 changed files with 3403 additions and 426 deletions
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace QuestionableCompanion.Models;
|
||||
|
||||
public class LANMessage
|
||||
{
|
||||
public LANMessageType Type { get; set; }
|
||||
|
||||
public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
|
||||
public string? Data { get; set; }
|
||||
|
||||
public LANMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public LANMessage(LANMessageType type, object? data = null)
|
||||
{
|
||||
Type = type;
|
||||
if (data != null)
|
||||
{
|
||||
Data = JsonConvert.SerializeObject(data);
|
||||
}
|
||||
}
|
||||
|
||||
public T? GetData<T>()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Data))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
return JsonConvert.DeserializeObject<T>(Data);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue