/// <summary> /// Unregisters the provided UnitOfWork instance /// </summary> /// <param name="uow"></param> protected internal void UnregisterUnitOfWork(IUnitOfWorkBase uow) { if (uow == null) { throw new ArgumentNullException(nameof(uow)); } Logger?.LogTrace("Unregistering UnitOfWork ({uow.id}, {uow.type}) in {dbCtx.type}...", uow.UowId, uow.GetType(), this.GetType()); //ThrowIfDisposingOrDisposed(); if (this.UowsById.TryRemove(uow.UowId, out var removedUow)) { if (!object.ReferenceEquals(uow, removedUow)) { throw new ArgumentException($"Unit of work instance removed by Id {uow.UowId} not equals the given instance!"); } Logger?.LogTrace("UnitOfWork ({uow.id}, {uow.type}) removed from {dbCtx.type}.", uow.UowId, uow.GetType(), this.GetType()); OnUnitOfWorkRemoved(uow); this.IsBusy = !this.UowsById.IsEmpty; } }
private void RegisterUnitOfWork(IUnitOfWorkBase uow) { if (uow == null) { throw new ArgumentNullException(nameof(uow)); } Logger?.LogTrace("Registering UnitOfWork ({uow.id}, {uow.type}) in {dbCtx.type}...", uow.UowId, uow.GetType(), this.GetType()); ThrowIfDisposingOrDisposed(); this.UowsById.Add(uow); OnUnitOfWorkAdded(uow); this.IsBusy = !this.UowsById.IsEmpty; }