-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathViewServicesConfiguration.cs
More file actions
75 lines (72 loc) · 2.75 KB
/
Copy pathViewServicesConfiguration.cs
File metadata and controls
75 lines (72 loc) · 2.75 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
using System.Reactive.Concurrency;
using ApplicationTemplate.DataAccess;
using Chinook.DynamicMvvm;
using MessageDialogService;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.UI.Dispatching;
using ReviewService;
namespace ApplicationTemplate.Views;
/// <summary>
/// This class is used for view services.
/// - Configures view services.
/// </summary>
public static class ViewServicesConfiguration
{
public static IServiceCollection AddViewServices(this IServiceCollection services)
{
return services
.AddSingleton(s => App.Instance.NavigationMultiFrame.DispatcherQueue)
.AddSingleton(s => Shell.Instance.ExtendedSplashScreen)
.AddSingleton<IDispatcherScheduler>(s => new MainDispatcherScheduler(
s.GetRequiredService<DispatcherQueue>(),
DispatcherQueuePriority.Normal
))
.AddSingleton<IDispatcherFactory, DispatcherFactory>()
.AddSingleton<IDiagnosticsService, DiagnosticsService>()
.AddSingleton<ILauncherService>(s => new LauncherService(s.GetRequiredService<DispatcherQueue>()))
.AddSingleton<IVersionProvider, VersionProvider>()
.AddSingleton<IAppStoreUriProvider, AppStoreUriProvider>()
.AddSingleton<IDeviceInformationProvider, DeviceInformationProvider>()
.AddSingleton<IExtendedSplashscreenController, ExtendedSplashscreenController>(s => new ExtendedSplashscreenController(Shell.Instance.DispatcherQueue))
.AddSingleton<IConnectivityProvider, ConnectivityProvider>()
.AddSingleton<IEmailService, EmailService>()
.AddSingleton<IMemoryProvider, MemoryProvider>()
.AddSingleton<IReviewPrompter, ReviewPrompter>()
#if __ANDROID__ || __IOS__
.AddSingleton<RemoteConfigRepository>()
.AddSingleton<IKillSwitchRepository>(s => s.GetRequiredService<RemoteConfigRepository>())
.AddSingleton<IMinimumVersionReposiory>(s => s.GetRequiredService<RemoteConfigRepository>())
#else
.AddSingleton<IKillSwitchRepository, KillSwitchRepositoryMock>()
.AddSingleton<IMinimumVersionReposiory, MinimumVersionRepositoryMock>()
#endif
.AddMessageDialog();
}
private static IServiceCollection AddMessageDialog(this IServiceCollection services)
{
return services.AddSingleton<IMessageDialogService>(s =>
//-:cnd:noEmit
#if __WINDOWS__ || __IOS__ || __ANDROID__
new MessageDialogService.MessageDialogService(
s.GetRequiredService<DispatcherQueue>(),
//-:cnd:noEmit
#if __WINDOWS__
new MessageDialogBuilderDelegate(
key => s.GetRequiredService<IStringLocalizer>()[key],
WinRT.Interop.WindowNative.GetWindowHandle(App.Instance.CurrentWindow)
)
#else
new MessageDialogBuilderDelegate(
key => s.GetRequiredService<IStringLocalizer>()[key]
)
#endif
//+:cnd:noEmit
)
#else
new AcceptOrDefaultMessageDialogService()
#endif
//+:cnd:noEmit
);
}
}