Example #1
0
        /// <summary>
        /// Creates the child container.
        /// </summary>
        /// <returns>Created container.</returns>
        public virtual IChildContainer CreateChildContainer()
        {
            var prevContainer = _childContainer;

            _childContainer = new ChildContainer(ServiceMappings, _storage, _factory.CreateScoped(),
                                                 () => _childContainer = prevContainer);
            return(_childContainer);
        }
        /// <summary>
        /// Dispose current child container (if any)
        /// </summary>
        public static void DisposeChildContainer()
        {
            if (_childContainer == null)
                return;

            _childContainer.Dispose();
            _childContainer = null;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChildContainerAdapter" /> class.
 /// </summary>
 /// <param name="childContainer">The child container (i.e. scoped container which will clean up scoped services when being disposed).</param>
 /// <exception cref="System.ArgumentNullException">childContainer</exception>
 public ChildContainerAdapter(IChildContainer childContainer)
 {
     if (childContainer == null)
     {
         throw new ArgumentNullException("childContainer");
     }
     _childContainer = childContainer;
 }
Example #4
0
        /// <summary>
        /// Gets the child container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <returns></returns>
        public IChildContainer GetChildContainer(IParentContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return(_childContainer ?? (_childContainer = container.CreateChildContainer()));
        }
Example #5
0
        /// <summary>
        /// Dispose current child container (if any)
        /// </summary>
        public static void DisposeChildContainer()
        {
            if (_childContainer == null)
            {
                return;
            }

            _childContainer.Dispose();
            _childContainer = null;
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Scope"/> class.
 /// </summary>
 /// <param name="container">The scoped container.</param>
 /// <param name="disposeAction">The dispose action (invoked when the scope is disposed).</param>
 public Scope(IChildContainer container, Action disposeAction)
 {
     _container     = container;
     _disposeAction = disposeAction;
 }
 public GriffinWebApiChildScope(IChildContainer childContainer)
 {
     _childContainer = childContainer;
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Scope"/> class.
 /// </summary>
 /// <param name="container">The scoped container.</param>
 /// <param name="disposeAction">The dispose action (invoked when the scope is disposed).</param>
 public Scope(IChildContainer container, Action disposeAction)
 {
     _container = container;
     _disposeAction = disposeAction;
 }
 public GriffinContainerScopeAdapter(IChildContainer container)
 {
     _scope = container ?? throw new ArgumentNullException(nameof(container));
     Interlocked.Increment(ref _currentScopes);
 }
Example #10
0
 public GriffinContainerScopeAdapter(IChildContainer container)
 {
     _container = container;
 }
Example #11
0
 public GriffinContainerScopeAdapter(IChildContainer container)
 {
     _container = container;
     Interlocked.Increment(ref CurrentScopes);
 }
 public void Dispose()
 {
     _scope?.Dispose();
     _scope = null;
 }
 public GriffinScopeAdapter(IChildContainer scope)
 {
     _scope = scope;
 }