Inheritance: IScope, IServiceProvider
示例#1
0
        internal SystemContext(ServiceContainer container)
        {
            scope = container.OpenScope(ContextNames.System);
            scope.RegisterInstance<ISystemContext>(this);

            EventRegistry = new EventRegistry(this);
        }
示例#2
0
        private ServiceContainer(ServiceContainer parent, string scopeName)
        {
            if (parent != null) {
                container = parent.container.OpenScope(scopeName)
                    .With(rules => rules.WithDefaultReuseInsteadOfTransient(Reuse.InCurrentNamedScope(scopeName)));

                ScopeName = scopeName;
            } else {
                container = new Container(Rules.Default);
            }

            // registrationProviders = new List<IRegistrationConfigurationProvider>();
        }
示例#3
0
        internal SystemContext(IConfiguration configuration, ServiceContainer container)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            Configuration = configuration;

            scope = container.OpenScope(ContextNames.System);
            scope.RegisterInstance<IConfiguration>(configuration);
            scope.RegisterInstance<ISystemContext>(this);

            EventRegistry = new EventRegistry(this);
        }
示例#4
0
        public void RegisterInstanceAndResolveAllFromChild()
        {
            var instance = new TestService1();

            var parent = new ServiceContainer();
            parent.RegisterInstance(instance);

            var child = parent.OpenScope("child");

            var services = child.ResolveAll<ITestService>();

            Assert.IsNotEmpty(services);
            Assert.AreEqual(1, services.Count());
        }
示例#5
0
        public void RegisterInstanceAndResolveFromChild()
        {
            var instance = new TestService1();

            var parent = new ServiceContainer();
            parent.RegisterInstance(instance);

            var child = parent.OpenScope("child");

            var childService = child.Resolve<ITestService>();

            Assert.IsNotNull(childService);
            Assert.IsInstanceOf<TestService1>(childService);
            Assert.AreEqual(instance, childService);
        }
 protected override void RegisterServices(ServiceContainer container)
 {
     container.UseSpatial();
 }
示例#7
0
 protected virtual void OnServiceRegistration(ServiceContainer container)
 {
 }
示例#8
0
 public SystemBuilder(IConfiguration configuration)
 {
     Configuration = configuration;
     ServiceContainer = new ServiceContainer();
 }
示例#9
0
        public void ResolveFromChildWithParentService()
        {
            var parent = new ServiceContainer();
            parent.Register<TestService1>();

            var child = parent.OpenScope("child");
            child.Register<TestService2>();

            var service2 = child.Resolve<TestService2>();

            Assert.IsNotNull(service2);
            Assert.IsNotNull(service2.Service1);
        }
示例#10
0
 protected override void OnServiceRegistration(ServiceContainer container)
 {
     test.RegisterServices(container);
 }
示例#11
0
 protected virtual void RegisterServices(ServiceContainer container)
 {
 }
示例#12
0
 public SystemBuilder()
 {
     ServiceContainer = new ServiceContainer();
 }