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);
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #4
0
 protected virtual void OnAfterFind()
 {
     EmbeddedDocumentUtility.UpdateParentReferences(this);
     ResetChanges();
     ExecuteObservers(CallbackType.AfterFind, o => o.AfterFind((T)this));
 }
Beispiel #5
0
 protected virtual bool OnBeforeSave()
 {
     EmbeddedDocumentUtility.UpdateParentReferences(this);
     return(ExecuteCancellableObservers(CallbackType.BeforeSave, o => o.BeforeSave((T)this)));
 }
Beispiel #6
0
 public void UpdateAssociations()
 {
     EmbeddedDocumentUtility.UpdateParentReferences(this);
 }