Beispiel #1
0
        protected BsonDocument Serialize(WebData_v2 <TSource, TData> webData)
        {
            BsonDocument document = new BsonDocument {
                _dataSerializer.Serialize(webData.Data)
            };
            //if (webData.HttpResults.Count == 1)
            //{
            //    document.Add(_webRequestSerializer.Serialize(webData.HttpResults.First().Value.Http.GetHttpLog()));
            //}
            //else
            //{
            BsonDocument httpDocument = new BsonDocument();

            foreach (KeyValuePair <string, HttpResult <string> > value in webData.HttpResults)
            {
                if (value.Value.Http != null)
                {
                    httpDocument.Add(new BsonElement(value.Key, _webRequestSerializer.SerializeAsDocument(value.Value.Http.GetHttpLog())));
                }
            }
            string itemName = _webRequestSerializer.ItemName;

            if (itemName == null)
            {
                throw new PBException("web request serializer item name is not defined");
            }
            document.Add(new BsonElement(itemName, httpDocument));
            //}
            return(document);
        }
        public BsonDocument Serialize(AggregateSnapshot snapshot)
        {
            return(new BsonDocument()
            {
                { AggregateIdElement, snapshot.AggregateId },
                { AggregateTypeElement, snapshot.AggregateType.AssemblyQualifiedName },
                { VersionElement, snapshot.Version },
                { TimestampElement, snapshot.Timestamp },

                { StateTypeElement, snapshot.State.GetType().AssemblyQualifiedName },
                { StateElement, _dataSerializer.Serialize(snapshot.State) },
            });
        }