private SimpleInjectorWebApiDependencyResolver(Container container, bool createScope)
        {
            _container = container;

            if (createScope)
            {
                _lifetimeScope = container.BeginLifetimeScope();
            }
        }
 internal void RemoveLifetimeScope(LifetimeScope scope)
 {
     // If the scope is not the current scope or one of its ancestors, this means that either one of
     // the scope's parents have already been disposed, or the scope is disposed on a completely
     // unrelated thread. In both cases we shouldn't change the CurrentScope, since doing this,
     // since would cause an invalid scope to be registered as the current scope (this scope will
     // either be disposed or does not belong to the current execution context).
     if (scope.IsCurrentScopeOrAncestor)
     {
         this.CurrentScope = scope.ParentScope;
     }
 }
        // Determines whether this instance is the currently registered lifetime scope or an ancestor of it.
        private bool IsScopeInLocalChain(LifetimeScope scope)
        {
            var currentScope = this.threadLocalScopes.Value;

            while (currentScope != null)
            {
                if (object.ReferenceEquals(scope, currentScope))
                {
                    return true;
                }

                currentScope = currentScope.ParentScope;
            }

            return false;
        }
Exemplo n.º 4
0
 internal LifetimeScope(LifetimeScopeManager manager, LifetimeScope parentScope) : base(manager.Container)
 {
     this.manager = manager;
     this.ParentScope = parentScope;
 }
 internal LifetimeScope BeginLifetimeScope()
 {
     return this.CurrentScope = new LifetimeScope(this, parentScope: this.CurrentScope);
 }
 internal LifetimeScope(LifetimeScopeManager manager, LifetimeScope parentScope)
 {
     this.manager = manager;
     this.ParentScope = parentScope;
     this.initialThreadId = Thread.CurrentThread.ManagedThreadId;
 }
Exemplo n.º 7
0
 internal LifetimeScope(LifetimeScopeManager manager, LifetimeScope parentScope)
 {
     this.manager = manager;
     this.ParentScope = parentScope;
 }
Exemplo n.º 8
0
 internal LifetimeScope(LifetimeScopeManager manager, LifetimeScope parentScope)
 {
     this.manager     = manager;
     this.ParentScope = parentScope;
 }
Exemplo n.º 9
0
 internal LifetimeScope(LifetimeScopeManager manager, LifetimeScope parentScope)
 {
     this.manager         = manager;
     this.ParentScope     = parentScope;
     this.initialThreadId = Thread.CurrentThread.ManagedThreadId;
 }
Exemplo n.º 10
0
 internal LifetimeScope BeginLifetimeScope()
 {
     return(this.CurrentScope = new LifetimeScope(this, parentScope: this.CurrentScope));
 }
Exemplo n.º 11
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SimpleInjectorLifetimeScope"/> class.
		/// </summary>
		/// <param name="provider">The provider.</param>
		public SimpleInjectorLifetimeScope(SimpleInjectorDIProvider provider)
		{
			Container = provider;

			_scope = provider.Container.BeginLifetimeScope();
		}
Exemplo n.º 12
0
 internal LifetimeScope(LifetimeScopeManager manager, LifetimeScope parentScope) : base(manager.Container)
 {
     this.manager     = manager;
     this.ParentScope = parentScope;
 }