protected void Application_Start(object sender, EventArgs e) { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); this.container = new UnityContainer(); UnityConfig.RegisterComponents(this.container); /* * No podemos inyectar dependencias en el Global.asax * Ver: * https://stackoverflow.com/questions/7752023/how-to-inject-dependencies-into-the-global-asax-cs * http://blog.ploeh.dk/2011/07/28/CompositionRoot/ */ string jsonConfiguration = File.ReadAllText(Server.MapPath("~") + "\\mutantConfiguration.json"); this.analyzerService = this.container.Resolve <IDNAAnalyzerService>(); this.analyzerService.Configure(jsonConfiguration); var mutantRepository = this.container.Resolve <IMutantRepository>(); mutantRepository.Initialize(ConfigurationManager.ConnectionStrings["Default"].ConnectionString); var statsRepository = this.container.Resolve <IStatsRepository>(); statsRepository.Initialize(ConfigurationManager.ConnectionStrings["Default"].ConnectionString); this.analyzerService.MutantRepository = mutantRepository; this.analyzerService.StatsRepository = statsRepository; ///Configure IDNAConfiguration singleton var dnaConfiguration = this.container.Resolve <IDNAConfiguration>(); dnaConfiguration.ComponentsPattern = ConfigurationManager.AppSettings["DnaComponentsPattern"]; ///Configure IDNAFactory singleton this.dnaFactory = this.container.Resolve <IDNAFactory>(); this.dnaFactory.DNAConfiguration = dnaConfiguration; }
public MutantController(IDNAAnalyzerService dnaAnalyzerService, IDNAFactory dnaFactory) { this.DNAAnalyzerService = dnaAnalyzerService; this.DNAFactory = dnaFactory; }
public StatsController(IDNAAnalyzerService dnaAnalyzerService) { this.DNAAnalyzerService = dnaAnalyzerService; }