forked from mohammadKarimi/SwiftLink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigServices.cs
More file actions
37 lines (32 loc) · 1.24 KB
/
ConfigServices.cs
File metadata and controls
37 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SwiftLink.Infrastructure.CacheProvider;
using SwiftLink.Infrastructure.Persistence.Context;
namespace SwiftLink.Infrastructure;
/// <summary>
/// This extension is programmed for registering Infrastructure services .
/// </summary>
public static class ConfigureServices
{
public static IServiceCollection RegisterInfrastructureServices(this IServiceCollection services,
IConfiguration configuration)
{
services.AddDbContext<IApplicationDbContext, ApplicationDbContext>(opt =>
{
opt.UseSqlServer(configuration.GetConnectionString(nameof(ApplicationDbContext)),
(db) => { db.MigrationsHistoryTable("MigrationHistory"); })
#if DEBUG
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
#endif
});
services.AddScoped<ApplicationDbContextInitializer>();
services.AddSingleton<ICacheProvider, RedisCacheService>();
services.AddStackExchangeRedisCache(opt =>
{
opt.Configuration = configuration["AppSettings:Redis:RedisCacheUrl"];
});
return services;
}
}