DisposeUnitOfWork() public static method

called internally to clear the current Unit Of Work and move to the previous one.
public static DisposeUnitOfWork ( IUnitOfWorkImplementor unitOfWork ) : void
unitOfWork IUnitOfWorkImplementor
return void
        /// <summary>
        /// Release resources
        /// </summary>
        /// <param name="disposing">release managed resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing && Count > 0)
            {
                var countOfUnitOfWork = Count;

                if (IsDebugEnabled)
                {
                    log.Debug("Disposing multiple unit of work... Count of UnitOfWork=[{0}]", countOfUnitOfWork);
                }

                With.TryAction(() => {
                    ForEach(implementor => With.TryAction(implementor.Dispose));

                    if (Count > 0 && TrueForAll(implementor => implementor.Previous != null))
                    {
                        UnitOfWork.DisposeUnitOfWork(this);
                    }
                });

                if (IsDebugEnabled)
                {
                    log.Debug("MultipleUnitOfWorkImplementor의 내부 IUnitOfWork 들을 Dispose 했습니다!!! 갯수=[{0}]", countOfUnitOfWork);
                }
            }
            IsDisposed = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Disposing a given Unit of work
        /// </summary>
        /// <param name="adapter">instance of IUnitOfWork to dispose.</param>
        public virtual void DisposeUnitOfWork(IUnitOfWorkImplementor adapter)
        {
            adapter.ShouldNotBeNull("adapter");

            if (IsDebugEnabled)
            {
                log.Debug("[{0}]를 Dispose합니다.", adapter.GetType().FullName);
            }

            ISession session = null;

            if (adapter.Previous != null)
            {
                session = adapter.Previous.Session;
            }

            CurrentSession = session;
            UnitOfWork.DisposeUnitOfWork(adapter);
        }