2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-26 21:13:13 +00:00

Generics workaround

This commit is contained in:
2022-06-05 02:06:59 +03:00
parent f1584b348d
commit 499f1e37d2
7 changed files with 89 additions and 78 deletions

View File

@ -284,7 +284,17 @@ public static class Codec
}
else
{
if (type.IsGenericType)
if (Codec.ImplementsInterface(type, typeof(IResource)))
{
var (hdr, data) = DataSerializer.ResourceComposer(valueOrSource, connection);
return TransmissionType.Compose(hdr, data);
}
else if (Codec.ImplementsInterface(type, typeof(IRecord)))
{
var (hdr, data) = DataSerializer.RecordComposer(valueOrSource, connection);
return TransmissionType.Compose(hdr, data);
}
else if (type.IsGenericType)
{
var genericType = type.GetGenericTypeDefinition();
if (genericType == typeof(List<>))
@ -326,17 +336,7 @@ public static class Codec
return TransmissionType.Compose(hdr, data);
//}
}
else if (Codec.ImplementsInterface(type, typeof(IResource)))
{
var (hdr, data) = DataSerializer.ResourceComposer(valueOrSource, connection);
return TransmissionType.Compose(hdr, data);
}
else if (Codec.ImplementsInterface(type, typeof(IRecord)))
{
var (hdr, data) = DataSerializer.RecordComposer(valueOrSource, connection);
return TransmissionType.Compose(hdr, data);
}
}
else if (type.IsEnum)
{
var (hdr, data) = DataSerializer.EnumComposer(valueOrSource, connection);