54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
namespace ln.types.odb.values
|
|
{
|
|
public class ODBInteger : ODBValue
|
|
{
|
|
public ODBInteger()
|
|
: base(0x10)
|
|
{
|
|
}
|
|
public ODBInteger(int i)
|
|
: this()
|
|
{
|
|
Value = i;
|
|
}
|
|
|
|
public override bool AsBool => AsInt != 0;
|
|
|
|
public override byte[] ToStorage() => BitConverter.GetBytes(AsInt);
|
|
|
|
static ODBInteger()
|
|
{
|
|
RegisterDeserializer(0x10, (b, o, l) => BitConverter.ToInt32(b, o));
|
|
//RegisterValueFactory(typeof(int), v => new ODBInteger((int)v));
|
|
//RegisterValueFactory(typeof(short), v => new ODBInteger((int)(short)v));
|
|
//RegisterValueFactory(typeof(byte), v => new ODBInteger((int)(byte)v));
|
|
}
|
|
|
|
}
|
|
public class ODBUInteger : ODBValue
|
|
{
|
|
public ODBUInteger()
|
|
: base(0x11)
|
|
{
|
|
}
|
|
public ODBUInteger(uint i)
|
|
: this()
|
|
{
|
|
Value = i;
|
|
}
|
|
|
|
public override byte[] ToStorage() => BitConverter.GetBytes(AsUInt);
|
|
|
|
static ODBUInteger()
|
|
{
|
|
RegisterDeserializer(0x11, (b, o, l) => BitConverter.ToUInt32(b, o));
|
|
//RegisterValueFactory(typeof(uint), v => new ODBUInteger((uint)v));
|
|
//RegisterValueFactory(typeof(ushort), v => new ODBUInteger((uint)(ushort)v));
|
|
//RegisterValueFactory(typeof(char), v => new ODBUInteger((uint)(char)v));
|
|
}
|
|
|
|
}
|
|
}
|