private void SetModifiedBySingle <T>(T entity) where T : IEntity { ThrowIfModifiedByIsEmpty <T>(); Cache <T> .ModifiedByProp?.SetValue( entity, BsonSerializer.Deserialize(ModifiedBy.ToBson(), Cache <T> .ModifiedByProp.PropertyType)); }
private void SetModifiedBySingle <T>(T entity) where T : IEntity { ThrowIfModifiedByIsEmpty <T>(); Cache <T> .ModifiedByProp?.SetValue( entity, BsonSerializer.Deserialize(ModifiedBy.ToBson(), Cache <T> .ModifiedByProp.PropertyType)); //note: we can't use an IModifiedBy interface because the above line needs a concrete type // to be able to correctly deserialize a user supplied derived/sub class of ModifiedOn. }
private void SetModifiedByMultiple <T>(IEnumerable <T> entities) where T : IEntity { if (Cache <T> .ModifiedByProp is null) { return; } ThrowIfModifiedByIsEmpty <T>(); var val = BsonSerializer.Deserialize(ModifiedBy.ToBson(), Cache <T> .ModifiedByProp.PropertyType); foreach (var e in entities) { Cache <T> .ModifiedByProp.SetValue(e, val); } }