53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
namespace ln.types.odb.values
|
|
{
|
|
public class ODBLong : ODBValue
|
|
{
|
|
public ODBLong()
|
|
: base(0x12)
|
|
{
|
|
}
|
|
public ODBLong(long i)
|
|
: this()
|
|
{
|
|
Value = i;
|
|
}
|
|
|
|
public override byte[] ToStorage() => BitConverter.GetBytes(AsLong);
|
|
|
|
public override DateTime AsDateTime => DateTimeOffset.FromUnixTimeMilliseconds(AsLong).DateTime;
|
|
public override TimeSpan AsTimeSpan => TimeSpan.FromMilliseconds(AsDouble);
|
|
|
|
|
|
static ODBLong()
|
|
{
|
|
RegisterDeserializer(0x12, (b, o, l) => BitConverter.ToInt64(b, o));
|
|
//RegisterValueFactory(typeof(long), v => new ODBLong((long)v));
|
|
//RegisterValueFactory(typeof(DateTime), v => new ODBLong(new DateTimeOffset((DateTime)v).ToUnixTimeMilliseconds()));
|
|
}
|
|
|
|
}
|
|
public class ODBULong : ODBValue
|
|
{
|
|
public ODBULong()
|
|
: base(0x13)
|
|
{
|
|
}
|
|
public ODBULong(ulong i)
|
|
: this()
|
|
{
|
|
Value = i;
|
|
}
|
|
|
|
public override byte[] ToStorage() => BitConverter.GetBytes(AsULong);
|
|
|
|
static ODBULong()
|
|
{
|
|
RegisterDeserializer(0x13, (b, o, l) => BitConverter.ToUInt64(b, o));
|
|
//RegisterValueFactory(typeof(ulong), v => new ODBULong((ulong)v));
|
|
}
|
|
|
|
}
|
|
}
|