53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
// /**
|
|
// * File: ODBByteBuffer.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 ln.type;
|
|
using System;
|
|
namespace ln.objects.catalog
|
|
{
|
|
public class ODBByteBuffer : ODBValue
|
|
{
|
|
public byte[] GetBytes() => (byte[])Value;
|
|
|
|
|
|
public ODBByteBuffer(byte[] bytes)
|
|
: base(0x0800, bytes.Slice(0))
|
|
{
|
|
}
|
|
|
|
public override byte[] Serialize() => GetBytes();
|
|
protected override int compare(ODBEntity other)
|
|
{
|
|
ODBByteBuffer you = other as ODBByteBuffer;
|
|
|
|
byte[] myBytes = GetBytes();
|
|
byte[] yourBytes = you.GetBytes();
|
|
|
|
int dl = myBytes.Length - yourBytes.Length;
|
|
|
|
if (dl != 0)
|
|
return dl;
|
|
|
|
while (dl < myBytes.Length)
|
|
{
|
|
int d = myBytes[dl] - yourBytes[dl++];
|
|
if (d != 0)
|
|
return d;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static ODBByteBuffer()
|
|
{
|
|
RegisterDeserializer(0x0800, (storageBytes, offset, length) => new ODBByteBuffer(storageBytes.Slice(offset, length)));
|
|
}
|
|
}
|
|
}
|