Exemplo n.º 1
0
        private static IServiceCollection ConfigureServices()
        {
            IServiceCollection services = new ServiceCollection();
            var    config           = LoadConfiguration();
            string connectionString = config.GetConnectionString("DefaultConnection");

            services.AddDbContext <PhotoBankDbContext>(options =>
            {
                options.UseSqlServer(connectionString,
                                     builder =>
                {
                    builder.MigrationsAssembly(typeof(PhotoBankDbContext).GetTypeInfo().Assembly.GetName().Name);
                    builder.UseNetTopologySuite();
                    builder.CommandTimeout(120);
                });
                options.EnableSensitiveDataLogging();
                options.EnableDetailedErrors();
            });

            RegisterServicesForConsole.Configure(services, config);

            services.AddSingleton(config);
            services.AddTransient <App>();

            services.AddAutoMapper(typeof(MappingProfile));
            services.AddLogging(configure => configure.AddSerilog());

            return(services);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });

            var connectionString = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <PhotoBankDbContext>(options =>
            {
                options.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddDebug()));
                options.UseSqlServer(connectionString,
                                     builder =>
                {
                    builder.MigrationsAssembly(typeof(PhotoBankDbContext).GetTypeInfo().Assembly.GetName().Name);
                    builder.UseNetTopologySuite();
                    builder.CommandTimeout(120);
                });
                options.EnableSensitiveDataLogging();
                options.EnableDetailedErrors();
            });

            RegisterServicesForConsole.Configure(services, Configuration);
            services.AddScoped <TooltipService>();

            services.AddAutoMapper(typeof(MappingProfile));
        }