diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-14 22:02:45 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-14 22:02:45 +0200 |
| commit | 76b22e4d05cbd8d771f678e4b5adc2dc5159afa8 (patch) | |
| tree | 815892d26cbf716d9fae9e01d46109299875d94d /Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs | |
| parent | f838a715af54ef7fc35bf9d99fee95dd8ac6533f (diff) | |
| download | Tango-76b22e4d05cbd8d771f678e4b5adc2dc5159afa8.tar.gz Tango-76b22e4d05cbd8d771f678e4b5adc2dc5159afa8.zip | |
Moved data store projects to DataStore folder.
Diffstat (limited to 'Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs deleted file mode 100644 index 5aa7c5342..000000000 --- a/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Google.Protobuf; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Bson; -using Tango.Core.ExtensionMethods; -using Tango.PMR; -using Tango.PMR.Common; -using Tango.PMR.DataStore; - -namespace Tango.DataStore -{ - public class DataStoreProtoObject - { - public MessageType MessageType { get; set; } - public Type Type { get; set; } - public byte[] Data { get; set; } - - - private IMessage _message; - [JsonIgnore] - public IMessage Message - { - get - { - if (_message == null) - { - _message = MessageFactory.ParseProtoMessage(Data, Type); - } - - return _message; - } - private set { _message = value; } - } - - public byte[] ToBytes() - { - return BsonConvert.Serialize<DataStoreProtoObject>(this); - } - - public static DataStoreProtoObject FromBytes(byte[] data) - { - var instance = BsonConvert.Deserialize<DataStoreProtoObject>(data); - instance.Message = MessageFactory.ParseProtoMessage(instance.Data, instance.Type); - - return instance; - } - - public static DataStoreProtoObject FromMessage(IMessage message) - { - DataStoreProtoObject proto = new DataStoreProtoObject(); - proto.Type = message.GetType(); - proto.MessageType = MessageFactory.ParseMessageType(proto.Type.Name); - proto.Data = message.ToByteArray(); - proto.Message = message; - return proto; - } - - public static DataStoreProtoObject FromJObject(JObject obj) - { - return (obj.ToObject<DataStoreProtoObject>()); - } - - public static DataStoreProtoObject FromPMRDataStoreItem(DataStoreItem item) - { - DataStoreProtoObject proto = new DataStoreProtoObject(); - proto.MessageType = item.ProtoType; - proto.Type = MessageFactory.GetPMRTypeFromMessageType(item.ProtoType); - proto.Data = item.BytesValue.ToByteArray(); - return proto; - } - - public override string ToString() - { - return Message?.ToJsonString(); - } - } -} |
