41 lines
1012 B
C#
41 lines
1012 B
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Xml.Serialization;
|
|
using ChaosBot.Attribute;
|
|
|
|
namespace ChaosBot.Database.Entity
|
|
{
|
|
[DBEntity("ServerConfigurationFlags")]
|
|
public class ServerConfigurationFlag<T>
|
|
{
|
|
public string key { get; }
|
|
|
|
public string serializedValue { get; }
|
|
|
|
public long guildId { get; }
|
|
|
|
public ServerConfigurationFlag(string key, T value, ulong guildId)
|
|
{
|
|
this.serializedValue = Serialize(value);
|
|
this.key = key;
|
|
this.guildId = Convert.ToInt64(guildId);
|
|
}
|
|
|
|
public T GetValue()
|
|
{
|
|
return Deserialize(serializedValue);
|
|
}
|
|
|
|
public static string Serialize(T value)
|
|
{
|
|
return JsonSerializer.Serialize(value);
|
|
}
|
|
|
|
public static T Deserialize(string serializedValue)
|
|
{
|
|
return JsonSerializer.Deserialize<T>(serializedValue);
|
|
}
|
|
}
|
|
} |