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;
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 8
0
        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
                }
            };
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 12
0
 public Function1(ServiceA service)
 {
     _service = service;
 }
Ejemplo n.º 13
0
 public ServiceB(ServiceA serviceA)
 {
     this.serviceA = serviceA;
 }
Ejemplo n.º 14
0
 public BAdapter(ServiceA serviceA)
 {
     _serviceA = serviceA;
 }
Ejemplo n.º 15
0
 public DisposableServiceB(ServiceA serviceA)
     : base(serviceA)
 {
 }
Ejemplo n.º 16
0
 public ServiceB(ServiceA serviceA)
 {
     ServiceA = serviceA;
 }
Ejemplo n.º 17
0
 public DefaultController(ServiceA serviceA, ServiceB serviceB, ServiceC serviceC)
 {
     this.serviceA = serviceA;
     this.serviceB = serviceB;
     this.serviceC = serviceC;
 }
Ejemplo n.º 18
0
 public ValuesController(IDbScopeFactory dbScopeFactory, ServiceA serviceA)
 {
     _dbScopeFactory = dbScopeFactory;
     _serviceA       = serviceA;
 }
Ejemplo n.º 19
0
 public ConcreteMediator(ServiceA serviceA, ServiceB serviceB)
 {
     (_serviceA, _serviceB) = (serviceA, serviceB);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 22
0
 public DefaultController(IDbScopeFactory dbScopeFactory, ServiceA serviceA)
 {
     _dbScopeFactory = dbScopeFactory;
     _serviceA       = serviceA;
 }
 public Root(ServiceA serviceA, ServiceB nsbServiceB)
 {
     ServiceA = serviceA;
     ServiceB = nsbServiceB;
 }
Ejemplo n.º 24
0
 public ServiceB(ServiceA serviceA)
 {
     ServiceA = serviceA;
 }
Ejemplo n.º 25
0
 public ServiceAll(ServiceA A, ServiceB B, ServiceC C)
 {
     serviceA = A;
     serviceB = B;
     serviceC = C;
 }
 public IServiceA ProvideServiceA(ServiceA service) => service;
Ejemplo n.º 27
0
 public ServiceE(ServiceD serviceD, ServiceA serviceA)
 {
     ServiceD = serviceD;
     ServiceA = serviceA;
 }
Ejemplo n.º 28
0
 public Facade()
 {
     _serviceA = new ServiceA();
     _serviceB = new ServiceB();
     _serviceC = new ServiceC();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 31
0
 public FooWithMultipleConstructors(ServiceA service, ServiceB serviceB)
 {
 }
Ejemplo n.º 32
0
 public ControllerB(ServiceA serviceA, ServiceB serviceB)
 {
     _serviceA = serviceA;
     _serviceB = serviceB;
 }
Ejemplo n.º 33
0
 public IServiceA ProvideServiceA(ServiceA service)
 {
     return(service);
 }
Ejemplo n.º 34
0
 public void RunAll()
 {
     ServiceA.RunA();
     ServiceB.RunB();
 }
Ejemplo n.º 35
0
 public FooWithMultipleConstructors(ServiceA service, ServiceB serviceB, ServiceC serviceC = null)
 {
     ConstructorCalled = true;
 }
 public SomeClassToResolve(ServiceA serviceA, ServiceB serviceB)
 {
     _serviceA = serviceA;
     _serviceB = serviceB;
 }
Ejemplo n.º 37
0
 public ServiceDependencyAll(ServiceA sva, ServiceB svb, ServiceC svc)
 {
     Service_A = sva;
     Service_B = svb;
     Service_C = svc;
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 40
0
Archivo: App.cs Proyecto: Im5tu/videos
 public App(ServiceA serviceA)
 {
     _service = serviceA;
 }