public NoInjectionController() { // TODO: read from config const string connectionString = "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=Demo;Integrated Security=SSPI;"; const int maxCountOfPrices = 3; // BOOKMARK: 1.2 no DI _dbConnection = new SqlConnection(connectionString); _companyPriceProvider = new CompanyPriceProvider( new CompanyService(new DbCompanyRepository(_dbConnection, new ConsoleLogger())), new PriceProvider( Options.Create(new PriceProviderOptions { MaxCountOfPrices = maxCountOfPrices }), new DbStockRepository(_dbConnection))); }
public DemoController(ICompanyPriceProvider companyPriceProvider) { // BOOKMARK: 1.1 DI _companyPriceProvider = companyPriceProvider; }
public DemoController(ICompanyPriceProvider companyPriceProvider) { _companyPriceProvider = companyPriceProvider; }
// BOOKMARK: 1.4 reuse public NewController(ICompanyPriceProvider companyPriceProvider, ILogger logger /* BOOKMARK: 1.5 add dependency */) { _companyPriceProvider = companyPriceProvider; _logger = logger; }