예제 #1
0
 private void SetModifiedBySingle <T>(T entity) where T : IEntity
 {
     ThrowIfModifiedByIsEmpty <T>();
     Cache <T> .ModifiedByProp?.SetValue(
         entity,
         BsonSerializer.Deserialize(ModifiedBy.ToBson(), Cache <T> .ModifiedByProp.PropertyType));
 }
예제 #2
0
        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.
        }
예제 #3
0
        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);
            }
        }