public AggregateSnapshot Deserialize(BsonDocument bsonDocument)
 {
     return(new AggregateSnapshot()
     {
         AggregateId = bsonDocument[AggregateIdElement].AsString,
         AggregateType = bsonDocument[AggregateTypeElement].AsType(),
         Version = bsonDocument[VersionElement].AsInt32,
         Timestamp = bsonDocument[TimestampElement].ToUniversalTime(),
         State = _dataSerializer.Deserialize(bsonDocument[StateElement].AsBsonDocument, bsonDocument[StateTypeElement].AsType())
     });
 }
Beispiel #2
0
        protected void Deserialize(WebData_v2 <TSource, TData> webData, BsonDocument document)
        {
            webData.Data = _dataSerializer.Deserialize(document);

            string itemName = _webRequestSerializer.ItemName;

            if (itemName == null)
            {
                throw new PBException("web request serializer item name is not defined");
            }
            if (!document.Contains(itemName))
            {
                throw new PBException($"deserialize web request : serializer document does'nt contain element \"{itemName}\"");
            }
            var element = document[itemName];

            if (element == null)
            {
                throw new PBException($"deserialize web request : element \"{itemName}\" is null");
            }
            if (!(element is BsonDocument))
            {
                throw new PBException($"deserialize web request : element \"{itemName}\" is not a document");
            }
            BsonDocument httpDocument = element as BsonDocument;

            foreach (BsonElement httpElement in httpDocument)
            {
                if (!(httpElement.Value is BsonDocument))
                {
                    throw new PBException($"deserialize web request : element \"{httpElement.Name}\" is not a document");
                }
                HttpLog httpLog = _webRequestSerializer.DeserializeData((BsonDocument)httpElement.Value);
                webData.HttpResults.Add(httpElement.Name, new HttpResult <string> {
                    Http = new Http_v2(httpLog)
                });
            }
        }
Beispiel #3
0
 public TData LoadFromId(BsonValue id)
 {
     return(_dataSerializer.Deserialize(_dataStore.LoadFromId(id)));
 }