aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-23 08:44:31 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-23 08:44:31 +0300
commit02ae577faa0bd4938507061d603e4f9447e2b64f (patch)
tree7daf0e275338ec92e93bfca39f2d529d93858162 /Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs
parent67770063ff1a1c5c522e3bc29f442c42eb6dc521 (diff)
downloadTango-02ae577faa0bd4938507061d603e4f9447e2b64f.tar.gz
Tango-02ae577faa0bd4938507061d603e4f9447e2b64f.zip
Fixed issue with insights file datetime utc.
added insights application exception/crash. added remote actions service. fixed issue with LiteDB hang on application start/exit. reduced insights listener empty frames.
Diffstat (limited to 'Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs')
-rw-r--r--Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs52
1 files changed, 2 insertions, 50 deletions
diff --git a/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs b/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs
index bb483e19a..6368a7754 100644
--- a/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs
+++ b/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs
@@ -10,6 +10,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.Bson;
using Tango.PMR;
using Tango.PMR.Common;
using Tango.PMR.Integration;
@@ -18,60 +19,11 @@ namespace Tango.Transport
{
public static class GenericMessageSerializer
{
- private class DateTimeConverter : JsonConverter
- {
- public override bool CanConvert(Type objectType)
- {
- return typeof(DateTime) == objectType
- || typeof(DateTime?) == objectType;
- }
-
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
- {
- var dateTimeOffset = (DateTime)value;
- // Serialize DateTimeOffset as round-trip formatted string
- serializer.Serialize(writer, dateTimeOffset.ToString("O"));
- }
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
- {
- if (reader.TokenType != JsonToken.String && reader.TokenType != JsonToken.Date)
- return null;
-
- DateTime dt;
-
- var dateWithOffset = (String)reader.Value;
-
- if (String.IsNullOrEmpty(dateWithOffset))
- return null;
-
- if (DateTime.TryParseExact(dateWithOffset, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dt))
- return dt;
-
- return null;
- }
-
- }
-
- private class DateTimeContractResolver : DefaultContractResolver
- {
- protected override JsonContract CreateContract(Type objectType)
- {
- var contract = base.CreateContract(objectType);
-
- if (objectType == typeof(DateTime) || objectType == typeof(DateTime?))
- contract.Converter = new DateTimeConverter();
-
- return contract;
- }
- }
-
private static JsonSerializer _serializer;
static GenericMessageSerializer()
{
- _serializer = new JsonSerializer() { ContractResolver = new DateTimeContractResolver() };
- _serializer.DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
+ _serializer = new BsonUtcSerializer();
ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddMissingTypes = true;
ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddProtoContractTypesOnly = false;