Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
        public void Exit(ILock theLock)
        {
            if (CanControlWithoutChaining(theLock))
            {
                ExitWithoutChaining(theLock);
            }
            else
            {
                if (_next == null)
                {
                    throw new ArgumentException(ExceptionMessages.LockNotSupportedByLockController, "theLock");
                }

                _next.Exit(theLock);
            }
        }