private void AfterSave(IIdentity id, IRepositoryEx repositoryEx, IAggregateEx aggregate) { //store the repository on the cache, actually we are keeping the very //same entity that was disposed by the caller. var cacheEntry = new CacheEntry(repositoryEx, aggregate); Cache.Add(id.AsString(), cacheEntry, _cachePolicy); }
public SingleUseAggregateCachedRepository( IRepositoryExFactory repositoryFactory, IIdentity id) { _repositoryFactory = repositoryFactory; _wrappedRepository = _repositoryFactory.Create(); _aggregate = _wrappedRepository.GetById <TAggregate>(id); }
public SqlDataContext() { SqlAnimalRepository repository = new SqlAnimalRepository(); AnimalType = repository; FellColor = repository; Location = repository; Region = repository; Animals = repository; }
/// <summary> /// /// </summary> /// <param name="wrappedRepository"></param> /// <param name="aggregate">When aggregate is not in cache this parameter is null and the /// instance of the aggregate is taken from the repository. </param> /// <param name="disposeAction"></param> /// <param name="afterSaveAction"></param> /// <param name="onExceptionAction"></param> /// <param name="id"></param> public CachableAggregateCachedRepository( IRepositoryEx wrappedRepository, TAggregate aggregate, Action <IIdentity, IRepositoryEx> disposeAction, Action <IIdentity, IRepositoryEx, IAggregateEx> afterSaveAction, Action <IIdentity, IRepositoryEx> onExceptionAction, IIdentity id) { _wrappedRepository = wrappedRepository; _disposeAction = disposeAction; _afterSaveAction = afterSaveAction; _onExceptionAction = onExceptionAction; _aggregate = aggregate ?? wrappedRepository.GetById <TAggregate>(id); }
public CacheEntry(IRepositoryEx repositoryEx, IAggregateEx aggregate) { RepositoryEx = repositoryEx; Aggregate = aggregate; }
private void OnException(IIdentity id, IRepositoryEx repositoryEx) { //remove the repository from cache, this will really dispose wrapped repository _repositoryFactory.Release(repositoryEx); Cache.Remove(id.AsString()); }
private void DisposeRepository(IIdentity id, IRepositoryEx repositoryEx) { //This is called when the repository is disposed. ReleaseAggregateId(id); }
protected ServiceEx(IRepositoryAsync <TEntity> repository) : base(repository) { _repositoryAsync = repository as IRepositoryEx <TEntity>; }