Exemple #1
0
        public void Singleton_Singleton_Singleton_RootScope()
        {
            // Arrange
            ContainerBuilder containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <FirstLayer>().As <IFirstLayer>().SingleInstance();
            containerBuilder.RegisterType <SecondLayer>().As <ISecondLayer>().SingleInstance();
            containerBuilder.RegisterType <ThirdLayer>().As <IThirdLayer>().SingleInstance();
            IContainer container = containerBuilder.Build();
            // Act
            IThirdLayer thirdLayer1 = container.Resolve <IThirdLayer>();
            IThirdLayer thirdLayer2 = container.Resolve <IThirdLayer>();

            // Assert
            thirdLayer1.AllInstanceNames.Should().Equal(thirdLayer2.AllInstanceNames);
        }
 public FourthLayer(IThirdLayer thirdLayer)
 {
     ThirdLayer = thirdLayer;
 }
Exemple #3
0
 public FourthLayerB(IThirdLayer thirdLayer, IThirdLayerA thirdLayerA, IThirdLayerB thirdLayerB)
 {
     ThirdLayer  = thirdLayer;
     ThirdLayerA = thirdLayerA;
     ThirdLayerB = thirdLayerB;
 }
Exemple #4
0
 //constructor injection for the win!
 public SomeBusinessLogicClass(IThirdLayer repository)
 {
     _repository = repository;
 }
 public FourthLayerA(IThirdLayer thirdLayer, IThirdLayerA thirdLayerA)
 {
     ThirdLayer  = thirdLayer;
     ThirdLayerA = thirdLayerA;
 }