public override object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            object result = CustomBsonClassMapSerializer.Instance.Deserialize(bsonReader, nominalType, actualType, options);

            if (result != null)
            {
                EmbeddedDocumentUtility.UpdateParentReferences(result);
            }
            return(result);
        }
Пример #2
0
        public void CanUpdateParentReferencesInProperty()
        {
            // Arrange.
            var person  = new Person();
            var address = new Address();

            // Act.
            person.Address = address;
            EmbeddedDocumentUtility.UpdateParentReferences(person);

            // Assert.
            Assert.That(address.Parent, Is.EqualTo(person));
        }
Пример #3
0
        public void CanUpdateParentReferencesInCollection()
        {
            // Arrange.
            var blogPost = new BlogPost();
            var comment  = new Comment();

            // Act.
            blogPost.Comments.Add(comment);
            EmbeddedDocumentUtility.UpdateParentReferences(blogPost);

            // Assert.
            Assert.That(comment.Parent, Is.EqualTo(blogPost));
        }
Пример #4
0
 protected virtual void OnAfterFind()
 {
     EmbeddedDocumentUtility.UpdateParentReferences(this);
     ResetChanges();
     ExecuteObservers(CallbackType.AfterFind, o => o.AfterFind((T)this));
 }
Пример #5
0
 protected virtual bool OnBeforeSave()
 {
     EmbeddedDocumentUtility.UpdateParentReferences(this);
     return(ExecuteCancellableObservers(CallbackType.BeforeSave, o => o.BeforeSave((T)this)));
 }
Пример #6
0
 public void UpdateAssociations()
 {
     EmbeddedDocumentUtility.UpdateParentReferences(this);
 }