Пример #1
0
        public void Intercept(IInvocation invocation)
        {
            bool lockEntered = false;

            try
            {
                var enterLock = _methodIncluder(invocation.Method);

                if (enterLock)
                {
                    _lockController.Enter(_lock, ref lockEntered);

                    if (!lockEntered)
                    {
                        throw new LockFailureException(ExceptionMessages.LockFailure);
                    }
                }

                invocation.Proceed();
            }
            finally
            {
                if (lockEntered)
                {
                    _lockController.Exit(_lock);
                }
            }
        }
Пример #2
0
        public void Enter(ILock theLock, ref bool lockTaken)
        {
            if (CanControlWithoutChaining(theLock))
            {
                EnterWithoutChaining(theLock, ref lockTaken);
            }
            else
            {
                if (_next == null)
                {
                    throw new ArgumentException(ExceptionMessages.LockNotSupportedByLockController, "theLock");
                }

                _next.Enter(theLock, ref lockTaken);
            }
        }