/// <summary>Returns item from transaction scope.</summary>
        /// <param name="scopeContext">Transaction scope context to select from.</param>
        /// <param name="request">Container Request info for resolving service</param>
        /// <param name="itemId">Scoped item ID for lookup.</param>
        /// <param name="createValue">Delegate for creating the item.</param>
        /// <returns>Reused item.</returns>
        public static object GetOrAddItemOrDefault(PerTransactionScopeContextBase scopeContext, Request request, int itemId, FactoryDelegate createValue, IResolverContext r)
        {
            if (scopeContext == null)
            {
                throw new ArgumentNullException(nameof(scopeContext));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

#pragma warning disable CA2000
            var scope = scopeContext.GetCurrentOrDefault(request.ServiceType);
#pragma warning restore CA2000
            return(scope?.GetOrAddViaFactoryDelegate(itemId, createValue, r));
        }
        /// <summary>Returns item from transaction scope.</summary>
        /// <param name="scopeContext">Transaction scope context to select from.</param>
        /// <param name="request">Container Request info for resolving service</param>
        /// <param name="itemId">Scoped item ID for lookup.</param>
        /// <param name="createValue">Delegate for creating the item.</param>
        /// <returns>Reused item.</returns>
        public static object GetOrAddItemOrDefault(PerTransactionScopeContextBase scopeContext, Request request, int itemId, CreateScopedValue createValue)
        {
            var scope = scopeContext.GetCurrentOrDefault(request.ServiceType);

            return(scope == null ? null : scope.GetOrAdd(itemId, createValue));
        }
 public PerTransactionReuseBase(PerTransactionScopeContextBase perTransactionScopeContextBase)
 {
     _PerTransactionScopeContextBase = perTransactionScopeContextBase;
 }