Example #1
0
        /// <summary>Sets the new scope as current using existing current as input.</summary>
        /// <param name="setCurrentScope">Delegate to get new scope.</param>
        /// <returns>New current scope.</returns>
        public IScope SetCurrent(SetCurrentScopeHandler setCurrentScope)
        {
            var oldScope = GetCurrentOrDefault();
            var newScope = setCurrentScope(oldScope);

            try
            {
                _getContextItems()[RootScopeName] = newScope;
                return(newScope);
            }
            catch (Exception ex)
            {
                if (_catchScopeContextErrors == null)
                {
                    throw;
                }
                _catchScopeContextErrors(ex);
                return(oldScope);
            }
        }
Example #2
0
 public IScope SetCurrent(SetCurrentScopeHandler setCurrentScope)
 {
     throw new NotSupportedException("Setting the new scope is not supported, because the transaction scope is created automatically.");
 }
Example #3
0
 /// <summary>Sets the new scope as current using existing current as input.</summary>
 /// <param name="setCurrentScope">Delegate to get new scope.</param>
 /// <returns>Return new current scope.</returns>
 public IScope SetCurrent(SetCurrentScopeHandler setCurrentScope)
 {
     var newCurrentScope = setCurrentScope.ThrowIfNull()(GetCurrentOrDefault());
     _getContextItems()[_currentScopeEntryKey] = newCurrentScope;
     return newCurrentScope;
 }
Example #4
0
 public IScope SetCurrent(SetCurrentScopeHandler setCurrentScope)
 {
     return(setCurrentScope(new Scope()));
 }
Example #5
0
 public IScope SetCurrent(SetCurrentScopeHandler setCurrentScope) => setCurrentScope(new Scope());