/// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCors(options => { options.AddPolicy("AnotherPolicy", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Matching Learning API", Version = "v1", Description = "The API for Matching Learning @Endava Innovation Lab 2019." }); //Locate the XML file being generated by ASP.NET... var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); //... and tell Swagger to use those XML comments. c.IncludeXmlComments(xmlPath); // c.IncludeXmlComments(Path.Combine(_env.ContentRootPath, "matching-learning.api.xml")); }); services.AddHttpContextAccessor(); services.AddSingleton <IProjectAnalyzer, ProjectAnalyzer>(sp => { var logger = sp.GetRequiredService <ILogger <ProjectAnalyzer> >(); var analyzer = new ProjectAnalyzer(logger, new SkillRepository()); analyzer.TrainModelIfNotExists(); return(analyzer); }); var photosRepo = new Repositories.FileSystemPhotoRepository(Path.Combine(_env.ContentRootPath, "Photos")); services.AddSingleton <Repositories.IPhotoRepository>(photosRepo); services.AddSingleton <Repositories.ISkillRepository, Repositories.SkillRepository>(); services.AddSingleton <IRegionRepository, RegionRepository>(); services.AddSingleton <IDeliveryUnitRepository, DeliveryUnitRepository>(); services.AddSingleton <IProjectRepository, ProjectRepository>(); services.AddSingleton <ICandidateRepository, CandidateRepository>(); services.AddSingleton <ICandidateRoleRepository, CandidateRoleRepository>(); services.AddSingleton <IEvaluationRepository, EvaluationRepository>(); services.AddSingleton <IEvaluationTypeRepository, EvaluationTypeRepository>(); services.AddSingleton <ISkillRepository, SkillRepository>(); GenFu.GenFu.Configure <CandidateModel>() .Fill(c => c.Name) .Fill(c => c.LastName); }