示例#1
0
        public LockUnitOfWorkScope(object syncRoot, IUnitOfWorkScopeProvider unitOfWorkScopeProvider)
        {
            #region Contracts

            if (syncRoot == null) throw new ArgumentNullException();
            if (unitOfWorkScopeProvider == null) throw new ArgumentNullException();

            #endregion

            // Arguments
            _syncRoot = syncRoot;

            // Enter
            try
            {
                // Monitor
                Monitor.Enter(_syncRoot);

                // UnitOfWorkScope
                _unitOfWorkScope = unitOfWorkScopeProvider.Create();
                if (_unitOfWorkScope == null) throw new InvalidOperationException();
            }
            catch
            {
                // Dispose
                this.Dispose();

                // Throw
                throw;
            }
        }
示例#2
0
        public LockUnitOfWorkScope(object syncRoot, IUnitOfWorkScopeProvider unitOfWorkScopeProvider)
        {
            #region Contracts

            if (syncRoot == null)
            {
                throw new ArgumentNullException();
            }
            if (unitOfWorkScopeProvider == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            // Arguments
            _syncRoot = syncRoot;

            // Enter
            try
            {
                // Monitor
                Monitor.Enter(_syncRoot);

                // UnitOfWorkScope
                _unitOfWorkScope = unitOfWorkScopeProvider.Create();
                if (_unitOfWorkScope == null)
                {
                    throw new InvalidOperationException();
                }
            }
            catch
            {
                // Dispose
                this.Dispose();

                // Throw
                throw;
            }
        }