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