diff --git a/Esiur/Data/Codec.cs b/Esiur/Data/Codec.cs
index 672d2be..ededea1 100644
--- a/Esiur/Data/Codec.cs
+++ b/Esiur/Data/Codec.cs
@@ -338,20 +338,11 @@ public static class Codec
};
-
- ///
- /// Compose a variable
- ///
- /// Value to compose.
- /// DistributedConnection is required to check locality.
- /// If True, prepend the DataType at the beginning of the output.
- /// Array of bytes in the network byte order.
- public static byte[] Compose(object valueOrSource, Warehouse warehouse, DistributedConnection connection)//, bool prependType = true)
+ internal static (TransmissionTypeIdentifier identifier, byte[])
+ ComposeInternal(object valueOrSource, Warehouse warehouse, DistributedConnection connection)
{
-
-
if (valueOrSource == null)
- return TransmissionType.Compose(TransmissionTypeIdentifier.Null, null);
+ return (TransmissionTypeIdentifier.Null, null);
var type = valueOrSource.GetType();
@@ -377,11 +368,8 @@ public static class Codec
if (valueOrSource is IUserType)
valueOrSource = ((IUserType)valueOrSource).Get();
- //if (valueOrSource is Func)
- // valueOrSource = (valueOrSource as Func)(connection);
-
if (valueOrSource == null)
- return TransmissionType.Compose(TransmissionTypeIdentifier.Null, null);
+ return (TransmissionTypeIdentifier.Null, null);
type = valueOrSource.GetType();
@@ -390,32 +378,32 @@ public static class Codec
if (Composers.ContainsKey(type))
{
var (hdr, data) = Composers[type](valueOrSource, warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
else
{
if (Codec.ImplementsInterface(type, typeof(IResource)))
{
var (hdr, data) = DataSerializer.ResourceComposer(valueOrSource, warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
else if (Codec.ImplementsInterface(type, typeof(IRecord)))
{
var (hdr, data) = DataSerializer.RecordComposer(valueOrSource, warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
else if (type.IsGenericType)
{
var genericType = type.GetGenericTypeDefinition();
- if (genericType == typeof(List<>)
- || genericType == typeof(VarList<>)
+ if (genericType == typeof(List<>)
+ || genericType == typeof(VarList<>)
|| genericType == typeof(IList<>))
{
var args = type.GetGenericArguments();
//if (Composers.ContainsKey(args[0]))
//{
var (hdr, data) = DataSerializer.TypedListComposer((IEnumerable)valueOrSource, args[0], warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
//}
}
else if (genericType == typeof(Map<,>))
@@ -423,15 +411,15 @@ public static class Codec
var args = type.GetGenericArguments();
var (hdr, data) = DataSerializer.TypedMapComposer(valueOrSource, args[0], args[1], warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
else if (genericType == typeof(Dictionary<,>))
{
var args = type.GetGenericArguments();
-
+
var (hdr, data) = DataSerializer.TypedDictionaryComposer(valueOrSource, args[0], args[1], warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
@@ -444,7 +432,7 @@ public static class Codec
)
{
var (hdr, data) = DataSerializer.TupleComposer(valueOrSource, warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
}
else if (type.IsArray)
@@ -454,23 +442,35 @@ public static class Codec
//if (Composers.ContainsKey(elementType))
//{
var (hdr, data) = DataSerializer.TypedListComposer((IEnumerable)valueOrSource, elementType, warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
//}
}
else if (type.IsEnum)
{
var (hdr, data) = DataSerializer.EnumComposer(valueOrSource, warehouse, connection);
- return TransmissionType.Compose(hdr, data);
+ return (hdr, data);
}
}
- return TransmissionType.Compose(TransmissionTypeIdentifier.Null, null);
+ return (TransmissionTypeIdentifier.Null, null);
}
+ ///
+ /// Compose a variable
+ ///
+ /// Value to compose.
+ /// DistributedConnection is required to check locality.
+ /// If True, prepend the DataType at the beginning of the output.
+ /// Array of bytes in the network byte order.
+ public static byte[] Compose(object valueOrSource, Warehouse warehouse, DistributedConnection connection)//, bool prependType = true)
+ {
+ var (hdr, data) = ComposeInternal(valueOrSource, warehouse, connection);
+ return TransmissionType.Compose(hdr, data);
+ }
public static bool IsAnonymous(Type type)
{
diff --git a/Esiur/Data/DataConverter.cs b/Esiur/Data/DataConverter.cs
index 9f7e884..92cec05 100644
--- a/Esiur/Data/DataConverter.cs
+++ b/Esiur/Data/DataConverter.cs
@@ -105,9 +105,12 @@ public static class DC // Data Converter
{
return Convert.ChangeType(value, destinationType);
}
+
}
- catch
+ catch (Exception ex)
{
+
+ throw ex;
return null;
}
}
@@ -317,7 +320,7 @@ public static class DC // Data Converter
-
+
public static byte[] ToBytes(this string value)
{
return Encoding.UTF8.GetBytes(value);
diff --git a/Esiur/Data/DataDeserializer.cs b/Esiur/Data/DataDeserializer.cs
index 71dfa4d..51961ef 100644
--- a/Esiur/Data/DataDeserializer.cs
+++ b/Esiur/Data/DataDeserializer.cs
@@ -1,14 +1,15 @@
using Esiur.Core;
+using Esiur.Data;
+using Esiur.Misc;
using Esiur.Net.IIP;
using Esiur.Resource;
+using Esiur.Resource.Template;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
-using System.Text;
-using Esiur.Data;
-using Esiur.Resource.Template;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
-using Esiur.Misc;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
+using System.Text;
namespace Esiur.Data;
@@ -676,8 +677,20 @@ public static class DataDeserializer
{
var rt = new List