aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreItem.cs
blob: 4327a0bd620972ee3ee76b11a6fc76730d14e20b (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
39
40
41
42
43
44
45
46
47
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.DataStore.Remote
{
    public class RemoteDataStoreItem : IDataStoreItem
    {
        public string Guid { get; set; }
        public string Key { get; set; }
        public DataType Type { get; set; }

        private object _value;
        public object Value
        {
            get
            {
                if (_value is JObject jObject)
                {
                    return (jObject.ToObject<DataStoreProtoObject>());
                }
                else
                {
                    return _value;
                }
            }
            set { _value = value; }
        }

        public DateTime Date { get; set; }
        public bool IsSynchronized { get; set; }

        public RemoteDataStoreItem()
        {
            Guid = System.Guid.NewGuid().ToString();
            Date = DateTime.UtcNow;
        }

        public override string ToString()
        {
            return DataStoreHelper.FormatDataStoreItem(this);
        }
    }
}