-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServiceRegistration.cs
More file actions
80 lines (72 loc) · 3.69 KB
/
ServiceRegistration.cs
File metadata and controls
80 lines (72 loc) · 3.69 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Nhs.Appointments.Core;
using Nhs.Appointments.Core.Availability;
using Nhs.Appointments.Core.Bookings;
using Nhs.Appointments.Core.Caching;
using Nhs.Appointments.Core.ClinicalServices;
using Nhs.Appointments.Core.Eula;
using Nhs.Appointments.Core.Messaging;
using Nhs.Appointments.Core.OdsCodes;
using Nhs.Appointments.Core.Reports;
using Nhs.Appointments.Core.Reports.SiteSummary;
using Nhs.Appointments.Core.Sites;
using Nhs.Appointments.Core.Users;
using Nhs.Appointments.Persistance.Models;
namespace Nhs.Appointments.Persistance;
public static class ServiceRegistration
{
public static IServiceCollection AddTypedCosmosDataStores(this IServiceCollection services)
{
var documentTypes = typeof(TypedCosmosDocument).Assembly
.GetTypes()
.Where(t => typeof(TypedCosmosDocument).IsAssignableFrom(t) && t.GetCustomAttribute<CosmosDocumentTypeAttribute>() != null);
foreach (var documentType in documentTypes)
{
var serviceType = typeof(ITypedDocumentCosmosStore<>).MakeGenericType(documentType);
var implementationType = typeof(TypedDocumentCosmosStore<>).MakeGenericType(documentType);
services.AddScoped(serviceType, implementationType);
}
return services;
}
public static IServiceCollection AddDocumentStores(this IServiceCollection services)
{
services
.AddScoped<IAvailabilityStore, AvailabilityDocumentStore>()
.AddScoped<IAvailabilityCreatedEventStore, AvailabilityCreatedEventDocumentStore>()
.AddScoped<IBookingsDocumentStore, BookingCosmosDocumentStore>()
.AddScoped<IReferenceNumberDocumentStore, ReferenceGroupCosmosDocumentStore>()
.AddScoped<IEulaStore, EulaStore>()
.AddScoped<IUserStore, UserStore>()
.AddScoped<IRolesStore, RolesStore>()
.AddScoped<ISiteStore, SiteStore>()
.AddScoped<IEmailWhitelistStore, EmailWhitelistStore>()
.AddScoped<INotificationConfigurationStore, NotificationConfigurationStore>()
.AddScoped<IAccessibilityDefinitionsStore, AccessibilityDefinitionsStore>()
.AddScoped<IWellKnownOdsCodesStore, WellKnownOdsCodesStore>()
.AddScoped<IClinicalServiceStore, ClinicalServiceStore>()
.AddScoped<IAggregationStore, AggregationStore>()
.AddScoped<IDailySiteSummaryStore, DailySiteSummaryStore>();
return services;
}
public static IServiceCollection AddServices(this IServiceCollection services)
{
services
.AddTransient<IRolesService, RolesService>()
.AddTransient<IWellKnowOdsCodesService, WellKnownOdsCodesService>()
.AddTransient<IBookingWriteService, BookingWriteService>()
.AddTransient<IBookingQueryService, BookingQueryService>()
.AddTransient<IAccessibilityDefinitionsService, AccessibilityDefinitionsService>()
.AddTransient<IAvailabilityWriteService, AvailabilityWriteService>()
.AddTransient<IAvailabilityQueryService, AvailabilityQueryService>()
.AddTransient<IBookingAvailabilityStateService, BookingAvailabilityStateService>()
.AddTransient<IEulaService, EulaService>()
.AddTransient<IUserService, UserService>()
.AddTransient<INotificationConfigurationService, NotificationConfigurationService>()
.AddTransient<ISiteReportService, SiteReportService>()
.AddScoped<ISiteService, SiteService>()
.AddTransient<ICacheStore, InMemoryCacheStore>()
.AddSingleton<ICacheService, CacheService>();
return services;
}
}