// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); // Add framework services. services.AddMvc() .AddDataAnnotationsLocalization(options => { options.DataAnnotationLocalizerProvider = (type, factory) => factory .Create(type.Name, LocTranslationSource.File.ToString()); }); services.AddNHibernate(m_configuration); var localizationConfiguration = m_configuration.GetSection("Localization").Get <LocalizationConfiguration>(); var databaseConfiguration = new NHibernateDatabaseConfiguration(); services.AddLocalizationService(localizationConfiguration, databaseConfiguration); m_container = new Container().WithDependencyInjectionAdapter( services, throwIfUnresolved: type => type.Name.EndsWith("Controller") ); return(m_container.Resolve <IServiceProvider>()); }
private static HbmMapping GetMappings() { var mapper = new ModelMapper(); mapper.AddMappings(NHibernateDatabaseConfiguration.GetMappings()); var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); return(mapping); }