/// <summary> /// Push unit of work to stack. /// </summary> public void PushUnitOfWork(IUnitOfWork unitOfWork) { var newContext = new UowContextStruct() { Parent = _currentContext, Current = unitOfWork }; _currentContext = newContext; }
/// <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); }