System.Transactions.TransactionScope.NeedToCreateTransaction C# (CSharp) Method

NeedToCreateTransaction() private method

private NeedToCreateTransaction ( TransactionScopeOption scopeOption ) : bool
scopeOption TransactionScopeOption
return bool
        private bool NeedToCreateTransaction(TransactionScopeOption scopeOption)
        {
            bool retVal = false;

            CommonInitialize();

            // If the options specify NoTransactionNeeded, that trumps everything else.
            switch (scopeOption)
            {
                case TransactionScopeOption.Suppress:
                    _expectedCurrent = null;
                    retVal = false;
                    break;

                case TransactionScopeOption.Required:
                    _expectedCurrent = _savedCurrent;
                    // If current is null, we need to create one.
                    if (null == _expectedCurrent)
                    {
                        retVal = true;
                    }
                    break;

                case TransactionScopeOption.RequiresNew:
                    retVal = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(scopeOption));
            }

            return retVal;
        }