Files
SteamTools/System.Common.CoreLib/Application/Models/JsonModel.cs
T
2021-03-05 00:18:50 +08:00

32 lines
706 B
C#

namespace System.Application.Models
{
public abstract class JsonModel
{
public override string ToString()
{
return Serializable.SJSON(this);
}
}
public abstract class JsonModel<T> : JsonModel where T : JsonModel<T>
{
public static T? Parse(string value)
{
return Serializable.DJSON<T>(value);
}
public static bool TryParse(string value, out T? result)
{
try
{
result = Parse(value);
return true;
}
catch
{
result = default;
return false;
}
}
}
}