ln.objects/catalog/ODBBool.cs

44 lines
1.0 KiB
C#

// /**
// * File: ODBBool.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
namespace ln.objects.catalog
{
public class ODBBool : ODBValue
{
public static ODBBool True = new ODBBool(true);
public static ODBBool False = new ODBBool(false);
bool isTrue;
private ODBBool(bool b)
: base(0x04, b)
{
isTrue = b;
}
public override byte[] Serialize() => new byte[] { isTrue ? (byte)0xFF : (byte)0x00 };
protected override int compare(ODBEntity other)
{
if (ReferenceEquals(this, other))
return 0;
if (isTrue)
return 1;
return -1;
}
static ODBBool()
{
RegisterDeserializer(0x04, (b, o, l) => b[o] != 0 ? True : False);
}
}
}