mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
Deadlock tests
This commit is contained in:
@@ -489,7 +489,9 @@ public static class Codec
|
||||
[typeof(Map<object?, object>)] = DataSerializer.MapComposer,
|
||||
[typeof(Map<object, object?>)] = DataSerializer.MapComposer,
|
||||
[typeof(Map<object?, object?>)] = DataSerializer.MapComposer,
|
||||
[typeof(PropertyValue[])] = DataSerializer.PropertyValueArrayComposer
|
||||
[typeof(PropertyValue[])] = DataSerializer.PropertyValueArrayComposer,
|
||||
// Sparse property delta for the reattach reply (index -> value/age/date).
|
||||
[typeof(Map<byte, PropertyValue>)] = DataSerializer.PropertyValueMapComposer
|
||||
// Typed
|
||||
// [typeof(bool[])] = (value, con) => DataSerializer.TypedListComposer((IEnumerable)value, typeof(bool), con),
|
||||
// [typeof(bool?[])] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
|
||||
|
||||
@@ -1898,6 +1898,31 @@ public static class DataDeserializer
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a sparse property delta produced by <c>PropertyValueMapComposer</c> (the reattach
|
||||
/// reply): a flat sequence of (index, age, date, value) TDUs, returned as a map keyed by the
|
||||
/// property index. Mirrors <see cref="PropertyValueArrayParserAsync"/> but in groups of four.
|
||||
/// </summary>
|
||||
public static AsyncReply<Map<byte, PropertyValue>> PropertyValueMapParserAsync(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
|
||||
{
|
||||
var rt = new AsyncReply<Map<byte, PropertyValue>>();
|
||||
|
||||
ListParserAsync(new ParsedTdu() { Data = data, PayloadOffset = offset, PayloadLength = length }
|
||||
, connection, requestSequence).Then(x =>
|
||||
{
|
||||
var ar = (object[])x;
|
||||
var map = new Map<byte, PropertyValue>();
|
||||
|
||||
for (var i = 0; i + 3 < ar.Length; i += 4)
|
||||
map[Convert.ToByte(ar[i])] =
|
||||
new PropertyValue(ar[i + 3], Convert.ToUInt64(ar[i + 1]), (DateTime?)ar[i + 2]);
|
||||
|
||||
rt.Trigger(map);
|
||||
});
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
public static async AsyncReply<ParseResult<PropertyValue>> PropertyValueParserAsync(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)//, bool ageIncluded = true)
|
||||
{
|
||||
|
||||
@@ -630,6 +630,31 @@ public static class DataSerializer
|
||||
(uint)rt.Count, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Composes a sparse property delta (index -> value/age/date) used by the reattach reply, as
|
||||
/// a flat sequence of (index, age, date, value) TDUs per modified property. PropertyValue is
|
||||
/// not a self-describing type, so this dedicated composer is used instead of the generic map
|
||||
/// path. Mirrors <see cref="PropertyValueArrayComposer"/> with a leading property index.
|
||||
/// </summary>
|
||||
public static Tdu PropertyValueMapComposer(object value, Warehouse warehouse, EpConnection connection)
|
||||
{
|
||||
if (value == null)
|
||||
return new Tdu(TduIdentifier.Null, new byte[0], 0, null, null);
|
||||
|
||||
var rt = new List<byte>();
|
||||
var map = (Map<byte, PropertyValue>)value;
|
||||
|
||||
foreach (var kv in map)
|
||||
{
|
||||
rt.AddRange(Codec.Compose(kv.Key, warehouse, connection)); // property index (u8)
|
||||
rt.AddRange(Codec.Compose(kv.Value.Age, warehouse, connection)); // age
|
||||
rt.AddRange(Codec.Compose(kv.Value.Date, warehouse, connection)); // modification date
|
||||
rt.AddRange(Codec.Compose(kv.Value.Value, warehouse, connection)); // value
|
||||
}
|
||||
|
||||
return new Tdu(TduIdentifier.RawData, rt.ToArray(), (uint)rt.Count, null, null);
|
||||
}
|
||||
|
||||
public static Tdu TypedMapComposer(object value, Type keyType, Type valueType, Warehouse warehouse, EpConnection connection)
|
||||
{
|
||||
if (value == null)
|
||||
|
||||
Reference in New Issue
Block a user