public Container Build()
        {
            if (hasBeenBuilt)
            {
                throw new InvalidOperationException("The container has been built.");
            }

            #region Please implement the code to pass the test

            /*
             * Since all the build operation can be considered as constructing the
             * ComponentRegistry. Please create a component registry and construct
             * its data. Then attach the registry to Container.
             *
             */
            var componentResitry = new ComponentRegistry();

            foreach (var callback in callbacks)
            {
                callback(componentResitry);
            }
            hasBeenBuilt = true;
            return(new Container(componentResitry));

            #endregion
        }
Пример #2
0
 public LifetimeScope(ComponentRegistry componentRegistry, ILifetimeScope parent)
 {
     if (componentRegistry == null)
     {
         throw new ArgumentNullException(nameof(componentRegistry));
     }
     this.componentRegistry = componentRegistry;
     RootScope = parent?.RootScope ?? this;
 }
        public LifetimeScope(ComponentRegistry componentRegistry, ILifetimeScope parent)
        {
            if (componentRegistry == null)
            {
                throw new ArgumentNullException(nameof(componentRegistry));
            }

            this.componentRegistry = componentRegistry;

            #region Please initialize root scope

            RootScope = parent?.RootScope ?? parent;
            #endregion
        }
        public LifetimeScope(ComponentRegistry componentRegistry, ILifetimeScope parent)
        {
            if (componentRegistry == null)
            {
                throw new ArgumentNullException(nameof(componentRegistry));
            }

            this.componentRegistry = componentRegistry;

            #region Please initialize root scope

            throw new NotImplementedException();

            #endregion
        }
Пример #5
0
        public Container Build()
        {
            if (hasBeenBuilt)
            {
                throw new InvalidOperationException("The container has been built.");
            }

            var componentRegistry = new ComponentRegistry();

            foreach (Action <ComponentRegistry> callback in callbacks)
            {
                callback(componentRegistry);
            }

            hasBeenBuilt = true;

            return(new Container(componentRegistry));
        }
Пример #6
0
 public LifetimeScope(ComponentRegistry componentRegistry)
 {
     this.componentRegistry = componentRegistry;
 }
 public LifetimeScope(ComponentRegistry componentRegistry)
     : this(componentRegistry, null)
 {
 }
Пример #8
0
 internal Container(ComponentRegistry componentRegistry)
 {
     this.componentRegistry = componentRegistry;
 }