mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-12-13 16:30:24 +00:00
GPModel
This commit is contained in:
@@ -483,12 +483,35 @@ public static class DataSerializer
|
|||||||
|
|
||||||
public static TDU ListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static TDU ListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var rt = ArrayComposer((IEnumerable)value, warehouse, connection);
|
if (value == null)
|
||||||
|
|
||||||
if (rt == null)
|
|
||||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||||
else
|
|
||||||
return new TDU(TDUIdentifier.List, rt, (uint)rt.Length);
|
var list = (IEnumerable)value;
|
||||||
|
|
||||||
|
var rt = new List<byte>();
|
||||||
|
|
||||||
|
TDU? previous = null;
|
||||||
|
|
||||||
|
foreach (var i in list)
|
||||||
|
{
|
||||||
|
var tdu = Codec.ComposeInternal(i, warehouse, connection);
|
||||||
|
if (previous != null && tdu.MatchType(previous.Value))
|
||||||
|
{
|
||||||
|
var d = tdu.Composed.Clip(tdu.ContentOffset,
|
||||||
|
(uint)tdu.Composed.Length - tdu.ContentOffset);
|
||||||
|
|
||||||
|
var ntd = new TDU(TDUIdentifier.TypeContinuation, d, (ulong)d.Length);
|
||||||
|
rt.AddRange(ntd.Composed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt.AddRange(tdu.Composed);
|
||||||
|
}
|
||||||
|
|
||||||
|
previous = tdu;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TDU(TDUIdentifier.List, rt.ToArray(), (uint)rt.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -690,7 +713,7 @@ public static class DataSerializer
|
|||||||
if (value == null)
|
if (value == null)
|
||||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||||
|
|
||||||
var composed = ArrayComposer((IEnumerable)value, warehouse, connection);
|
var composed = DynamicArrayComposer((IEnumerable)value, warehouse, connection);
|
||||||
|
|
||||||
return new TDU(TDUIdentifier.ResourceList, composed,
|
return new TDU(TDUIdentifier.ResourceList, composed,
|
||||||
(uint)composed.Length);
|
(uint)composed.Length);
|
||||||
@@ -701,7 +724,7 @@ public static class DataSerializer
|
|||||||
if (value == null)
|
if (value == null)
|
||||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||||
|
|
||||||
var composed = ArrayComposer((IEnumerable)value, warehouse, connection);
|
var composed = DynamicArrayComposer((IEnumerable)value, warehouse, connection);
|
||||||
|
|
||||||
return new TDU(TDUIdentifier.RecordList,
|
return new TDU(TDUIdentifier.RecordList,
|
||||||
composed, (uint)composed.Length);
|
composed, (uint)composed.Length);
|
||||||
@@ -799,9 +822,9 @@ public static class DataSerializer
|
|||||||
{
|
{
|
||||||
var propValue = pt.PropertyInfo.GetValue(record, null);
|
var propValue = pt.PropertyInfo.GetValue(record, null);
|
||||||
|
|
||||||
if (propValue == null)
|
//if (propValue == null)
|
||||||
return new TDU(TDUIdentifier.Null, null, 0);
|
// return TDU(TDUIdentifier.Null, null, 0);
|
||||||
var tru = TRU.FromType(propValue.GetType());
|
var tru = TRU.FromType(propValue?.GetType());
|
||||||
var tdu = Codec.ComposeInternal(propValue, warehouse, connection);
|
var tdu = Codec.ComposeInternal(propValue, warehouse, connection);
|
||||||
|
|
||||||
|
|
||||||
@@ -851,7 +874,7 @@ public static class DataSerializer
|
|||||||
foreach (var t in types)
|
foreach (var t in types)
|
||||||
metadata.AddRange(t);
|
metadata.AddRange(t);
|
||||||
|
|
||||||
var composed = ArrayComposer(list, warehouse, connection);
|
var composed = DynamicArrayComposer(list, warehouse, connection);
|
||||||
|
|
||||||
if (composed == null)
|
if (composed == null)
|
||||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ namespace Esiur.Data
|
|||||||
|
|
||||||
public static TRU? FromType(Type type)
|
public static TRU? FromType(Type type)
|
||||||
{
|
{
|
||||||
|
if (type == null)
|
||||||
|
return new TRU(TRUIdentifier.Void, true);
|
||||||
|
|
||||||
var nullable = false;
|
var nullable = false;
|
||||||
|
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ public class TypeTemplate
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return $"{type.Namespace.Replace('.', separator)}{separator}{type.Name}";
|
return $"{type.Namespace?.Replace('.', separator) ?? "Global"}{separator}{type.Name}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user