/// <summary> /// UnRegisters a <see cref="UnitOfWorkScope"/> as the top level scope on the stack. /// </summary> /// <param name="scope"></param> private static void UnRegisterScope(UnitOfWorkScope scope) { Guard.Against <ArgumentNullException>(scope == null, "Cannot Un-Register a null UnitOfWorkScope instance as the top level scope."); Guard.Against <InvalidOperationException>(RunningScopes.Peek() != scope, "The UnitOfWorkScope provided does not match the current top level scope. Cannot un-register the specified scope."); RunningScopes.Pop(); if (RunningScopes.Count > 0) { //If the Stack has additional scopes, set the current unit of work to the UnitOfWork instance held by the top most scope. UnitOfWorkScope currentScope = RunningScopes.Peek(); Data.UnitOfWork.Current = currentScope.UnitOfWork; } else { Data.UnitOfWork.Current = null; } }
private void UnRegisterScope(UnitOfWorkScope scope) { if (RunningScopes.Peek() != scope) { throw new InvalidOperationException("Cannot un-register scope."); } RunningScopes.Pop(); if (RunningScopes.Count > 0) { UnitOfWorkScope currentScope = RunningScopes.Peek(); UnitOfWork.Current = currentScope.RelUnitOfWork; } else { UnitOfWork.Current = null; } }