Esempio n. 1
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            _clientAppSettings        = configuration.GetSection("ClientApp").Get <ClientAppSettings>();
            _connectionstringSettings = configuration.GetSection("ConnectionStrings").Get <ConnectionstringSettings>();
        }
Esempio n. 2
0
        public HistoricContext CreateDbContext(string[] args)
        {
            var designtimeConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=Historic;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            var options = new ConnectionstringSettings {
                DefaultConnection = designtimeConnectionString
            };

            return(new HistoricContext(options));
        }
        internal void InitializeContainer(IApplicationBuilder app, ClientAppSettings clientAppSettings, ConnectionstringSettings connectionstringSettings)
        {
            var executingAssembly = Assembly.GetExecutingAssembly();
            var allAssemblies     = new[] { executingAssembly };

            // Add application presentation components:
            _container.RegisterMvcControllers(app);

            // Register settings as singleton
            _container.RegisterInstance(clientAppSettings);
            _container.RegisterInstance(connectionstringSettings);

            // Add application services. For instance:
            _container.Register(typeof(IQueryHandler <,>), allAssemblies);
            _container.Register(typeof(ICommandHandler <>), allAssemblies);
            _container.Register <HistoricContext>(Lifestyle.Scoped);

            // Add crosswiring services.

            // Allow Simple Injector to resolve services from ASP.NET Core.
            _container.AutoCrossWireAspNetComponents(app);

            using (AsyncScopedLifestyle.BeginScope(_container)) {
                var context = _container.GetInstance <HistoricContext>();
                context.Database.Migrate();
            }

            _container.Verify();
        }
Esempio n. 4
0
 public HistoricContext(ConnectionstringSettings settings)
 {
     _settings = settings;
 }