Inheritance: Service
        public void RegisterExtension_RegisterMultipleInstances()
        {
            DefaultExtensionRegistry registry = new DefaultExtensionRegistry();

            ServiceA serviceA = new ServiceA();
            ServiceB serviceB = new ServiceB();
            ServiceC serviceC = new ServiceC();
            registry.RegisterExtension(typeof(IMyService), serviceA);
            registry.RegisterExtension(typeof(IMyService), serviceB);
            registry.RegisterExtension(typeof(IMyService), serviceC);

            OtherServiceA otherServiceA = new OtherServiceA();
            OtherServiceB otherServiceB = new OtherServiceB();
            registry.RegisterExtension(typeof(IMyOtherService), otherServiceA);
            registry.RegisterExtension(typeof(IMyOtherService), otherServiceB);

            object[] services = registry.GetExtensions(typeof(IMyService)).ToArray();
            Assert.Equal(3, services.Length);
            Assert.True(services.Contains(serviceA));
            Assert.True(services.Contains(serviceB));
            Assert.True(services.Contains(serviceC));

            services = registry.GetExtensions(typeof(IMyOtherService)).ToArray();
            Assert.Equal(2, services.Length);
            Assert.True(services.Contains(otherServiceA));
            Assert.True(services.Contains(otherServiceB));
        }
        public ServiceDSimple(ServiceA serviceA, ServiceB serviceB, ServiceY serviceY)
        {
            if(serviceB == null) throw new ArgumentNullException("serviceB");

            this.ServiceB = serviceB;
            this.ServiceY = serviceY;
        }
Example #3
0
        public ServiceC(ServiceA serviceA, ServiceB serviceB)
        {
            if(serviceA == null) throw new ArgumentNullException("serviceA");
            if(serviceB == null) throw new ArgumentNullException("serviceB");

            this.serviceA = serviceA;
            this.serviceB = serviceB;
        }
        public void add_singleton_service()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceA a = new ServiceA();
            c.AddService(typeof(ServiceA), a);

            Assert.That(c.GetService<ServiceA>(), Is.SameAs(a));
        }
Example #5
0
        public ServiceD(ServiceA serviceA, IServiceB serviceB, ServiceY serviceY)
        {
            if(serviceA == null) throw new ArgumentNullException("serviceA");
            if(serviceB == null) throw new ArgumentNullException("serviceB");

            this.serviceA = serviceA;
            this.serviceB = serviceB;
            this.ServiceY = serviceY;
        }
        public void dedupe_by_name_services()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceA a1 = new ServiceA();
            c.AddService("hello", a1);
            c.AddService("other", a1);

            Assert.That(c.GetServices<ServiceA>().Count(), Is.EqualTo(1));
        }
        public void add_multiple_services()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceA a1 = new ServiceA();
            ServiceA a2 = new ServiceA();
            c.AddService(typeof(ServiceA), a1);
            c.AddService("other", a2);

            Assert.That(c.GetServices<ServiceA>(), Contains.Item(a1));
            Assert.That(c.GetServices<ServiceA>(), Contains.Item(a2));
        }
        private void RegisterPropertyInjection()
        {
            IServiceA serviceA = new ServiceA();
            IServiceB serviceB = new ServiceB();
            IServiceC serviceC = new ServiceC();

            this.container[typeof(IComplexPropertyObject)] = () =>
                                                             new ComplexPropertyObject
            {
                ServiceA   = serviceA,
                ServiceB   = serviceB,
                ServiceC   = serviceC,
                SubObjectA = new SubObjectA {
                    ServiceA = serviceA
                },
                SubObjectB = new SubObjectB {
                    ServiceB = serviceB
                },
                SubObjectC = new SubObjectC {
                    ServiceC = serviceC
                }
            };
        }
Example #9
0
        public void Inject()
        {
            var builder        = new ContainerBuilder();
            var container      = builder.Build();
            var childContainer = container.CreateScope(childBuilder =>
            {
                childBuilder.Register <I2, NoDependencyServiceA>(Lifetime.Singleton);
            });

            var methodInjectable = new HasMethodInjection();

            Assert.That(methodInjectable.Service2, Is.Null);

            childContainer.Inject(methodInjectable);
            Assert.That(methodInjectable.Service2, Is.InstanceOf <I2>());

            var noInjectable = new NoDependencyServiceA();

            Assert.DoesNotThrow(() => childContainer.Inject(noInjectable));

            var ctorInjectable = new ServiceA(new NoDependencyServiceA());

            Assert.DoesNotThrow(() => childContainer.Inject(ctorInjectable));
        }
 public DefaultController(ServiceA serviceA, ServiceB serviceB)
 {
     _serviceA = serviceA;
     _serviceB = serviceB;
 }
 public DummyMessageHandler(Context testContext, IUniformSession session, ServiceA serviceA)
 {
     this.testContext = testContext;
     this.session     = session;
     this.serviceA    = serviceA;
 }
Example #12
0
 public Function1(ServiceA service)
 {
     _service = service;
 }
Example #13
0
 public ServiceB(ServiceA serviceA)
 {
     this.serviceA = serviceA;
 }
Example #14
0
 public BAdapter(ServiceA serviceA)
 {
     _serviceA = serviceA;
 }
Example #15
0
 public DisposableServiceB(ServiceA serviceA)
     : base(serviceA)
 {
 }
Example #16
0
 public ServiceB(ServiceA serviceA)
 {
     ServiceA = serviceA;
 }
Example #17
0
 public DefaultController(ServiceA serviceA, ServiceB serviceB, ServiceC serviceC)
 {
     this.serviceA = serviceA;
     this.serviceB = serviceB;
     this.serviceC = serviceC;
 }
Example #18
0
 public ValuesController(IDbScopeFactory dbScopeFactory, ServiceA serviceA)
 {
     _dbScopeFactory = dbScopeFactory;
     _serviceA       = serviceA;
 }
Example #19
0
 public ConcreteMediator(ServiceA serviceA, ServiceB serviceB)
 {
     (_serviceA, _serviceB) = (serviceA, serviceB);
 }
Example #20
0
 // As "ServiceB" also has the ServiceBinding attribute, this constructor will also be called during server startup,
 // but since "ServiceA" is specified as a parameter (dependency), it will only be started after "ServiceA" has loaded.
 public ServiceB(ServiceA serviceA)
 {
     Log.Info("Service B Loaded!");
 }
 public ServiceB(ServiceA serviceA, string someValue)
 {
     this.serviceA  = serviceA;
     this.someValue = someValue;
 }
Example #22
0
 public DefaultController(IDbScopeFactory dbScopeFactory, ServiceA serviceA)
 {
     _dbScopeFactory = dbScopeFactory;
     _serviceA       = serviceA;
 }
 public Root(ServiceA serviceA, ServiceB nsbServiceB)
 {
     ServiceA = serviceA;
     ServiceB = nsbServiceB;
 }
 public ServiceB(ServiceA serviceA)
 {
     ServiceA = serviceA;
 }
 public ServiceAll(ServiceA A, ServiceB B, ServiceC C)
 {
     serviceA = A;
     serviceB = B;
     serviceC = C;
 }
 public IServiceA ProvideServiceA(ServiceA service) => service;
Example #27
0
 public ServiceE(ServiceD serviceD, ServiceA serviceA)
 {
     ServiceD = serviceD;
     ServiceA = serviceA;
 }
Example #28
0
 public Facade()
 {
     _serviceA = new ServiceA();
     _serviceB = new ServiceB();
     _serviceC = new ServiceC();
 }
Example #29
0
 public ServiceC(ServiceA serviceA, ServiceB serviceB)
 {
     this.serviceA = serviceA;
     this.serviceB = serviceB;
 }
 public ServiceB(ServiceA serviceA, string someValue)
 {
     this.serviceA = serviceA;
     this.someValue = someValue;
 }
 public FooWithMultipleConstructors(ServiceA service, ServiceB serviceB)
 {
 }
Example #32
0
 public ControllerB(ServiceA serviceA, ServiceB serviceB)
 {
     _serviceA = serviceA;
     _serviceB = serviceB;
 }
Example #33
0
 public IServiceA ProvideServiceA(ServiceA service)
 {
     return(service);
 }
Example #34
0
 public void RunAll()
 {
     ServiceA.RunA();
     ServiceB.RunB();
 }
 public FooWithMultipleConstructors(ServiceA service, ServiceB serviceB, ServiceC serviceC = null)
 {
     ConstructorCalled = true;
 }
 public SomeClassToResolve(ServiceA serviceA, ServiceB serviceB)
 {
     _serviceA = serviceA;
     _serviceB = serviceB;
 }
Example #37
0
 public ServiceDependencyAll(ServiceA sva, ServiceB svb, ServiceC svc)
 {
     Service_A = sva;
     Service_B = svb;
     Service_C = svc;
 }
Example #38
0
 public MyController(ServiceA serviceA, ServiceB serviceB)
 {
     this.serviceA = serviceA;
     this.serviceB = serviceB;
 }
        public void IExtensionRegistryExtensions_RegisterAndRetrieve()
        {
            DefaultExtensionRegistry registry = new DefaultExtensionRegistry();

            // use the generic extension methods to register
            ServiceA serviceA = new ServiceA();
            ServiceB serviceB = new ServiceB();
            ServiceC serviceC = new ServiceC();
            registry.RegisterExtension<IMyService>(serviceA);
            registry.RegisterExtension<IMyService>(serviceB);
            registry.RegisterExtension<IMyService>(serviceC);

            IMyService[] services = registry.GetExtensions<IMyService>().ToArray();
            Assert.Equal(3, services.Length);
            Assert.True(services.Contains(serviceA));
            Assert.True(services.Contains(serviceB));
            Assert.True(services.Contains(serviceC));
        }
Example #40
0
File: App.cs Project: Im5tu/videos
 public App(ServiceA serviceA)
 {
     _service = serviceA;
 }