예제 #1
0
        private void SynchronizeRepositories()
        {
            // if one persists, but not the other, then the persistable one wins
            // otherwise, go with the repository most recently changed
            IDataMapper <T> master = _secondary;
            IDataMapper <T> slave  = _primary;

            if ((_primary.CanPersist && !_secondary.CanPersist) ||
                (_primary.LastModified > _secondary.LastModified &&
                 _primary.CanPersist == _secondary.CanPersist))
            {
                master = _primary;
                slave  = _secondary;
            }

            RepositoryId[] ids = master.GetAllItems();

            // avoid doing anything which would change LastModifiedTime if both are empty
            if (ids.Length == 0 && slave.CountAllItems() == 0)
            {
                return;
            }

            slave.DeleteAllItems();

            foreach (RepositoryId id in ids)
            {
                T slaveItem = slave.CreateItem();
                _copyStrategy(slaveItem, master.GetItem(id));
            }
        }
예제 #2
0
 public void DeleteAllItems()
 {
     _decoratedDataMapper.DeleteAllItems();
     _caches.DeleteAllItemsFromCaches();
 }
예제 #3
0
 public void DeleteAllItems()
 {
     _primary.DeleteAllItems();
     _secondary.DeleteAllItems();
 }