Exemplo n.º 1
0
        /// <summary>
        /// Push unit of work to stack.
        /// </summary>
        public void PushUnitOfWork(IUnitOfWork unitOfWork)
        {
            var newContext = new UowContextStruct()
            {
                Parent  = _currentContext,
                Current = unitOfWork
            };

            _currentContext = newContext;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Pop the latest unit of work.Return to the previous unit of work(now is lasted).
        /// If no result ,reutrn null.
        /// </summary>
        public IUnitOfWork PopUnitOfWork()
        {
            // if is root . it's parent is null.
            if (_currentContext?.Parent == null)
            {
                _currentContext = null;
                return(null);
            }

            _currentContext = _currentContext.Parent;

            return(_currentContext.Current);
        }