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

            EventRegistry = new EventRegistry(this);
        }
Esempio n. 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>();
        }
Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 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();
 }
Esempio n. 7
0
 protected virtual void OnServiceRegistration(ServiceContainer container)
 {
 }
Esempio n. 8
0
 public SystemBuilder(IConfiguration configuration)
 {
     Configuration = configuration;
     ServiceContainer = new ServiceContainer();
 }
Esempio n. 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);
        }
Esempio n. 10
0
 protected override void OnServiceRegistration(ServiceContainer container)
 {
     test.RegisterServices(container);
 }
Esempio n. 11
0
 protected virtual void RegisterServices(ServiceContainer container)
 {
 }
Esempio n. 12
0
 public SystemBuilder()
 {
     ServiceContainer = new ServiceContainer();
 }