private static void ConfigureServices(ConnectionOptions options) { var builder = new ConfigurationBuilder() #if DEBUG .SetBasePath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..")) #endif #if RELEASE .SetBasePath(Environment.CurrentDirectory) #endif .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var configuration = builder.Build(); DiConfigurator.SetUp(services => { services.AddSingleton(new MongoClient(options.ConnectionString)); services.AddSingleton <IMongoDatabase>(a => a.GetService <MongoClient>().GetDatabase(options.DatabaseName)); services.AddSingleton <TransactionsDbProcessor>(); services.AddSingleton(new CancellationTokenSource()); services.AddDomain(); services.AddSingleton(options); //Entity framework services.AddDbContext <DatabaseContext>(a => { a.UseNpgsql(configuration["ConnectionStrings:SenseMiningStore"]); }); }); }
public void ConfigureServices(IServiceCollection services) { DiConfigurator.Configure(services, Configuration); services .AddControllers() .SetCompatibilityVersion(CompatibilityVersion.Latest); }
private static void ConfigureServices() { var builder = new ConfigurationBuilder() #if DEBUG .SetBasePath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..")) #endif #if RELEASE .SetBasePath(Environment.CurrentDirectory) #endif .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var configuration = builder.Build(); DiConfigurator.SetUp(services => { services.AddDomain(); //Entity framework services.AddDbContext <DatabaseContext>(a => { a.UseNpgsql(configuration["ConnectionStrings:SenseMiningStore"]); }); services.AddScoped <CancellationTokenSource>(); //MassTransit services.AddScoped <TransactionsQueueConsumer>(); services.AddMassTransit(c => { c.AddConsumer <TransactionsQueueConsumer>(); }); services.AddSingleton(provider => Bus.Factory.CreateUsingRabbitMq( cfg => { var host = cfg.Host(new Uri(configuration["RabbitMq:Host"]), hostConfigurator => { hostConfigurator.Username(configuration["RabbitMq:UserName"]); hostConfigurator.Password(configuration["RabbitMq:Password"]); hostConfigurator.Heartbeat(10); }); cfg.ReceiveEndpoint(host, e => { e.PrefetchCount = 16; e.UseMessageRetry(x => x.Interval(2, 100)); e.Durable = false; e.LoadFrom(provider); EndpointConvention.Map <TransactionsQueueConsumer>(e.InputAddress); }); })); services.AddSingleton <IBus>(provider => provider.GetRequiredService <IBusControl>()); services.AddSingleton <IHostedService, BusService>(); }); }
// 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.AddOptions(); services.AddMvc(); var connectionString = Configuration.GetConnectionString("DefaultConnection"); var diConfigurator = new DiConfigurator(connectionString, Configuration); diConfigurator.ConfigureServices(services); services.Configure <TravelxSettings>(Configuration.GetSection("TravelxSettings")); ConfigureApplicationCookie(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var diConfigurator = new DiConfigurator(Configuration); diConfigurator.ConfigureServices(services); services.Configure <ApplicationSettings>(Configuration.GetSection("ApplicationSettings")); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }