public void ReleaseModel(IDomainModelState model, ReleaseAction releaseAction) { var proxy = DomainModelStateProxy.Unwrap(model); switch (releaseAction) { case ReleaseAction.AcceptChanges: if (_nextState != proxy.Model) { throw new InvalidOperationException("Attempt to override current state detected."); } _currentState = _nextState; _nextState = null; _stateLock.ExitWriteLock(); break; case ReleaseAction.DiscardChanges: break; default: throw new ArgumentException( string.Format("Invalid release action '{0}' specified.", releaseAction), "releaseAction"); } proxy.Detach(); _stateLock.ExitReadLock(); }
public IDomainModelState PromoteToWriteModel(IDomainModelState model) { var proxy = DomainModelStateProxy.Unwrap(model); if (_currentState != proxy.Model) { throw new InvalidOperationException("Attempt to override current state detected."); } if (proxy.AcquireReason != AcquireReason.ForCommand) { throw new InvalidOperationException("Model acquired for query execution could not be promoted to writable mode."); } // TODO: create new state var nextState = new DomainModelState(); _stateLock.EnterWriteLock(); _nextState = nextState; return DomainModelStateProxy.Wrap(nextState, AcquireReason.ForCommand); }
public UnitOfWork(IEventPublisher eventPublisher, IDomainModelState model) { _eventPublisher = eventPublisher; _model = model; }
private static IEnumerable<IEventSource> GetEventSources(IDomainModelState model) { // TODO: throw new NotImplementedException(); }
public IUnitOfWork Create(IDomainModelState model) { // TODO: use container-aware factory return new UnitOfWork(_eventPublisher, model); }