/// <summary>
        /// Method invoked <i>instead</i> of the method to which the aspect has been applied.
        /// </summary>
        /// <param name="args">Advice arguments.</param>
        public override void OnInvoke(MethodInterceptionArgs args)
        {
            IExecuteActionStrategy strategy = null;

            if (CustomStrategy != null)
            {
                strategy = ExecuteActionStrategy.GetSingleton(CustomStrategy);
            }
            else if (_strategy != null)
            {
                switch (_strategy.Value)
                {
                case StandardExecutionStrategy.HandleReprocessableException:
                    strategy = ExecuteActionStrategy.HandleReprocessableException;
                    break;

                case StandardExecutionStrategy.NoReprocess:
                    strategy = ExecuteActionStrategy.NoReprocess;
                    break;

                case StandardExecutionStrategy.HandleUniqueConstraintViolation:
                    strategy = ExecuteActionStrategy.HandleUniqueConstraintViolation;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            GetDomain().ExecuteInternal(IsolationLevel, _transactionOpenMode, strategy, session => args.Proceed());
        }
예제 #2
0
        internal static T ExecuteInternal <T>(
            this Domain domain,
            IsolationLevel isolationLevel,
            TransactionOpenMode?transactionOpenMode,
            IExecuteActionStrategy strategy,
            Func <Session, T> func)
        {
            ReprocessingConfiguration config = domain.GetReprocessingConfiguration();

            if (strategy == null)
            {
                strategy = ExecuteActionStrategy.GetSingleton(config.DefaultExecuteStrategy);
            }
            if (transactionOpenMode == null)
            {
                transactionOpenMode = config.DefaultTransactionOpenMode;
            }
            return(strategy.Execute(new ExecutionContext <T>(domain, isolationLevel, transactionOpenMode.Value, func)));
        }