Ejemplo n.º 1
0
 /// <summary>
 /// Registers a scope as the top level scope on the <see cref="RunningScopes"/> stack.
 /// </summary>
 /// <param name="scope">The <see cref="UnitOfWorkScope"/> instance to set as the top level scope on the stack.</param>
 private static void RegisterScope(UnitOfWorkScope scope)
 {
     Guard.Against <ArgumentNullException>(scope == null,
                                           "Cannot register a null UnitOfWorkScope instance as the top level scope.");
     Data.UnitOfWork.Current = scope.UnitOfWork;
     //Setting the UnitOfWork isntance held by the scope as the current scope.
     RunningScopes.Push(scope);
 }
Ejemplo n.º 2
0
        /// <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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 private void RegisterScope(UnitOfWorkScope scope)
 {
     UnitOfWork.Current = scope.RelUnitOfWork;
     RunningScopes.Push(scope);
 }