public MunqUseCase() { container = new Container().UsesDefaultLifetimeManagerOf(lifetime); container.Register<IWebService>( c => new WebService( c.Resolve<IAuthenticator>(), c.Resolve<IStockQuote>())); container.Register<IAuthenticator>( c => new Authenticator( c.Resolve<ILogger>(), c.Resolve<IErrorHandler>(), c.Resolve<IDatabase>())); container.Register<IStockQuote>( c => new StockQuote( c.Resolve<ILogger>(), c.Resolve<IErrorHandler>(), c.Resolve<IDatabase>())); container.Register<IDatabase>( c => new Database( c.Resolve<ILogger>(), c.Resolve<IErrorHandler>())); container.Register<IErrorHandler>( c => new ErrorHandler(c.Resolve<ILogger>())); container.RegisterInstance<ILogger>(new Logger()); }
static StructureMapSingletonUseCase() { container = new Container(); container.Configure( x => x.For<IWebService>() .Use<WebService>()); container.Configure( x => x.For<IAuthenticator>().Singleton() .Use<Authenticator>()); container.Configure( x => x.For<IStockQuote>().Singleton() .Use<StockQuote>()); container.Configure( x => x.For<IDatabase>().Singleton() .Use<Database>()); container.Configure( x => x.For<IErrorHandler>().Singleton() .Use<ErrorHandler>()); container.Configure( x => x.For<ILogger>().Singleton() .Use(c => new Logger())); }
private static void SetValuesToAllBottles(KeyDataCollection bottlesInformation, int containerCounter, out List <Container> containerList) { containerList = new List <Container>(); for (var counter = 1; counter <= containerCounter; counter++) { var iniKey = "BOTTLE" + counter; var newContainer = new Container() { ContainerId = counter, ContainerValue = bottlesInformation[iniKey] }; containerList.Add(newContainer); } }
public StructureMapUseCase() { container = new Container(); container.Configure( x => x.ForRequestedType<IWebService>() .TheDefault.Is.ConstructedBy( c => new WebService( c.GetInstance<IAuthenticator>(), c.GetInstance<IStockQuote>()) )); container.Configure( x => x.ForRequestedType<IAuthenticator>() .TheDefault.Is.ConstructedBy( c => new Authenticator( c.GetInstance<ILogger>(), c.GetInstance<IErrorHandler>(), c.GetInstance<IDatabase>()) )); container.Configure( x => x.ForRequestedType<IStockQuote>() .TheDefault.Is.ConstructedBy( c => new StockQuote( c.GetInstance<ILogger>(), c.GetInstance<IErrorHandler>(), c.GetInstance<IDatabase>()) )); container.Configure( x => x.ForRequestedType<IDatabase>() .TheDefault.Is.ConstructedBy( c => new Database( c.GetInstance<ILogger>(), c.GetInstance<IErrorHandler>()) )); container.Configure( x => x.ForRequestedType<IErrorHandler>() .TheDefault.Is.ConstructedBy( c => new ErrorHandler(c.GetInstance<ILogger>()) )); container.Configure( x => x.ForRequestedType<ILogger>() .TheDefault.IsThis(new Logger())); }