internal ScopedContainerBuilder(
     IObjectResolver root,
     IScopedObjectResolver parent)
 {
     this.root   = root;
     this.parent = parent;
 }
Exemplo n.º 2
0
 internal Container(IRegistry registry)
 {
     this.registry  = registry;
     rootScope      = new ScopedContainer(registry, this);
     createInstance = registration =>
     {
         return(new Lazy <object>(() => registration.SpawnInstance(this)));
     };
 }
Exemplo n.º 3
0
 internal ScopedContainer(
     IRegistry registry,
     IObjectResolver root,
     IScopedObjectResolver parent = null)
 {
     this.registry  = registry;
     Root           = root;
     Parent         = parent;
     createInstance = registration =>
     {
         return(new Lazy <object>(() => registration.SpawnInstance(this)));
     };
 }
Exemplo n.º 4
0
        IRegistration FindRegistration(Type type)
        {
            IScopedObjectResolver scope = this;

            while (scope != null)
            {
                if (scope.TryGetRegistration(type, out var registration))
                {
                    return(registration);
                }
                scope = scope.Parent;
            }
            throw new VContainerException(type, $"No such registration of type: {type.FullName}");
        }