Esempio n. 1
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()));
        }
Esempio n. 2
0
        private IChildContainer CreateAndStartChildContainer()
        {
            var child = _container.CreateChildContainer();

            foreach (var startable in child.ResolveAll <IScopedStartable>())
            {
                startable.StartScoped();
            }
            return(child);
        }
Esempio n. 3
0
        /// <summary>
        /// Begins the scope.
        /// </summary>
        /// <returns></returns>
        public IDependencyScope BeginScope()
        {
            var child = _container.CreateChildContainer();

            _currentChild = new Scope(child, () => _currentChild = null);
            foreach (var startable in child.ResolveAll <IScopedStartable>())
            {
                startable.StartScoped();
            }

            return(_currentChild);
        }
        /// <summary>
        /// Invoked through reflection
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="domainEvent"></param>
        protected void TriggerPublish <T>(T domainEvent) where T : class
        {
            using (var child = _container.CreateChildContainer())
            {
                _scopeListener.Started(child);
                var success = true;
                foreach (var subscriber in child.ResolveAll <ISubscriberOf <T> >())
                {
                    try
                    {
                        subscriber.Handle(domainEvent);
                    }
                    catch (Exception err)
                    {
                        _scopeListener.Failure(child, domainEvent, subscriber, err);
                        success = false;
                        break; // do not continue
                    }
                }

                _scopeListener.Ended(child, success);
            }
        }
 public IContainerScope CreateScope()
 {
     return(new GriffinContainerScopeAdapter(_container.CreateChildContainer()));
 }
Esempio n. 6
0
        public IHandlerScope CreateScope()
        {
            var scope = _container.CreateChildContainer();

            return(new GriffinScopeAdapter(scope));
        }
 /// <summary>
 /// Create a new child scope.
 /// </summary>
 /// <returns>A new child scope</returns>
 public IScopedContainer CreateScope()
 {
     return(new ChildContainerAdapter(_container.CreateChildContainer()));
 }