blob: 20d5211e7754c74d73b59ca142b9b0883b981bc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using LiteDB;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tango.Telemetry
{
public class TelemetryBase : ITelemetry
{
[BsonIgnore] //This will be used for column mapping in ADX
public String Type
{
get { return this.ToTelemetryName(); }
}
public DateTime Time { get; set; }
public byte[] ToBytes(Formatting format = Formatting.None, bool flatten = true)
{
return Encoding.UTF8.GetBytes(ToJson(format, flatten));
}
public string ToJson(Formatting format = Formatting.None, bool flatten = true)
{
if (flatten)
{
return JsonFlattener.FlattenObjectToFlatJson(this, format);
}
else
{
return JsonConvert.SerializeObject(this, format);
}
}
}
}
|