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; }
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)); }
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 } }; }
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; }
public Function1(ServiceA service) { _service = service; }
public ServiceB(ServiceA serviceA) { this.serviceA = serviceA; }
public BAdapter(ServiceA serviceA) { _serviceA = serviceA; }
public DisposableServiceB(ServiceA serviceA) : base(serviceA) { }
public ServiceB(ServiceA serviceA) { ServiceA = serviceA; }
public DefaultController(ServiceA serviceA, ServiceB serviceB, ServiceC serviceC) { this.serviceA = serviceA; this.serviceB = serviceB; this.serviceC = serviceC; }
public ValuesController(IDbScopeFactory dbScopeFactory, ServiceA serviceA) { _dbScopeFactory = dbScopeFactory; _serviceA = serviceA; }
public ConcreteMediator(ServiceA serviceA, ServiceB serviceB) { (_serviceA, _serviceB) = (serviceA, serviceB); }
// 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; }
public DefaultController(IDbScopeFactory dbScopeFactory, ServiceA serviceA) { _dbScopeFactory = dbScopeFactory; _serviceA = serviceA; }
public Root(ServiceA serviceA, ServiceB nsbServiceB) { ServiceA = serviceA; ServiceB = nsbServiceB; }
public ServiceAll(ServiceA A, ServiceB B, ServiceC C) { serviceA = A; serviceB = B; serviceC = C; }
public IServiceA ProvideServiceA(ServiceA service) => service;
public ServiceE(ServiceD serviceD, ServiceA serviceA) { ServiceD = serviceD; ServiceA = serviceA; }
public Facade() { _serviceA = new ServiceA(); _serviceB = new ServiceB(); _serviceC = new ServiceC(); }
public ServiceC(ServiceA serviceA, ServiceB serviceB) { this.serviceA = serviceA; this.serviceB = serviceB; }
public FooWithMultipleConstructors(ServiceA service, ServiceB serviceB) { }
public ControllerB(ServiceA serviceA, ServiceB serviceB) { _serviceA = serviceA; _serviceB = serviceB; }
public IServiceA ProvideServiceA(ServiceA service) { return(service); }
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; }
public ServiceDependencyAll(ServiceA sva, ServiceB svb, ServiceC svc) { Service_A = sva; Service_B = svb; Service_C = svc; }
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)); }
public App(ServiceA serviceA) { _service = serviceA; }