mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-09-13 20:43:19 +00:00
1
This commit is contained in:
@@ -14,146 +14,146 @@ namespace Esiur.Data;
|
||||
|
||||
public static class DataDeserializer
|
||||
{
|
||||
public static AsyncReply NullParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object NullParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AsyncReply BooleanTrueParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object BooleanTrueParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static AsyncReply BooleanFalseParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object BooleanFalseParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<bool>(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static AsyncReply NotModifiedParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object NotModifiedParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<NotModified>(new NotModified());
|
||||
return NotModified.Default;
|
||||
}
|
||||
|
||||
public static AsyncReply ByteParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object ByteParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<byte>(data[offset]);
|
||||
return data[offset];
|
||||
}
|
||||
public static AsyncReply SByteParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object SByteParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<sbyte>((sbyte)data[offset]);
|
||||
return (sbyte)data[offset];
|
||||
}
|
||||
public static unsafe AsyncReply Char16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Char16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<char>(*(char*)ptr);
|
||||
return *(char*)ptr;
|
||||
}
|
||||
|
||||
public static AsyncReply Char8Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object Char8Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<char>((char)data[offset]);
|
||||
return (char)data[offset];
|
||||
}
|
||||
|
||||
|
||||
public static unsafe AsyncReply Int16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Int16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<short>(*(short*)ptr);
|
||||
return *(short*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply UInt16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object UInt16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<ushort>(*(ushort*)ptr);
|
||||
return *(ushort*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply Int32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Int32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<int>(*(int*)ptr);
|
||||
return *(int*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply UInt32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe uint UInt32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<uint>(*(uint*)ptr);
|
||||
return *(uint*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply Float32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Float32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<float>(*(float*)ptr);
|
||||
return *(float*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply Float64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Float64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<double>(*(double*)ptr);
|
||||
return *(double*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply Float128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Float128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<decimal>(*(decimal*)ptr);
|
||||
return *(decimal*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply Int128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Int128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<decimal>(*(decimal*)ptr);
|
||||
return *(decimal*)ptr;
|
||||
}
|
||||
|
||||
|
||||
public static unsafe AsyncReply UInt128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object UInt128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<decimal>(*(decimal*)ptr);
|
||||
return *(decimal*)ptr;
|
||||
}
|
||||
|
||||
|
||||
public static unsafe AsyncReply Int64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object Int64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<long>(*(long*)ptr);
|
||||
return *(long*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply UInt64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object UInt64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<ulong>(*(ulong*)ptr);
|
||||
return *(ulong*)ptr;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply DateTimeParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object DateTimeParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return new AsyncReply<DateTime>(new DateTime(*(long*)ptr, DateTimeKind.Utc));
|
||||
return new DateTime(*(long*)ptr, DateTimeKind.Utc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static unsafe AsyncReply ResourceParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object ResourceParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return connection.Fetch(*(uint*)ptr, requestSequence);
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply LocalResourceParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object LocalResourceParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
fixed (byte* ptr = &data[offset])
|
||||
return Warehouse.GetById(*(uint*)ptr);
|
||||
}
|
||||
|
||||
|
||||
public static unsafe AsyncReply RawDataParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object RawDataParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<byte[]>(data.Clip(offset, length));
|
||||
return data.Clip(offset, length);
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply StringParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object StringParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return new AsyncReply<string>(data.GetString(offset, length));
|
||||
return data.GetString(offset, length);
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply RecordParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object RecordParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
|
||||
var reply = new AsyncReply<IRecord>();
|
||||
@@ -229,7 +229,7 @@ public static class DataDeserializer
|
||||
return reply;
|
||||
}
|
||||
|
||||
public static unsafe AsyncReply ConstantParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
public static unsafe object ConstantParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -268,7 +268,7 @@ public static class DataDeserializer
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
var (cs, reply) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (cs, reply) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
rt.Add(reply);
|
||||
|
||||
@@ -292,7 +292,7 @@ public static class DataDeserializer
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
var (cs, reply) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (cs, reply) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
rt.Add(reply);
|
||||
|
||||
@@ -317,7 +317,7 @@ public static class DataDeserializer
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
var (cs, reply) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (cs, reply) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
rt.Add(reply);
|
||||
|
||||
@@ -354,7 +354,7 @@ public static class DataDeserializer
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
var (cs, reply) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (cs, reply) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
|
||||
results.Add(reply);
|
||||
@@ -404,7 +404,7 @@ public static class DataDeserializer
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
var (cs, reply) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (cs, reply) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
results.Add(reply);
|
||||
|
||||
@@ -459,7 +459,7 @@ public static class DataDeserializer
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
var (cs, reply) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (cs, reply) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
rt.Add(reply);
|
||||
|
||||
@@ -510,7 +510,7 @@ public static class DataDeserializer
|
||||
offset += 8;
|
||||
|
||||
|
||||
var (valueSize, results) = Codec.Parse(data, offset, connection, requestSequence);
|
||||
var (valueSize, results) = Codec.ParseAsync(data, offset, connection, requestSequence);
|
||||
|
||||
results.Then(value =>
|
||||
{
|
||||
|
Reference in New Issue
Block a user