コード例 #1
0
        public Container(IEnumerable <ServiceDescriptor> descriptors)
        {
            _serviceRegistry = new ServiceRegistry();
            foreach (var descriptor in descriptors)
            {
                var registration = new RegisteredService(descriptor);
                _serviceRegistry.AddRegistration(registration);
            }

            ServiceDescriptor containerDescriptor = new ServiceDescriptor(typeof(IContainer), c => this, ServiceLifetime.Singleton);
            var containerRegistration             = new RegisteredService(containerDescriptor);

            _serviceRegistry.AddRegistration(containerRegistration);

            RootContainer = this;
            ContainerId   = Guid.NewGuid();
        }