|
1 | 1 | using System;
|
2 | 2 | using System.Linq;
|
3 |
| -using System.Reflection; |
4 | 3 | using Windows.ApplicationModel.Activation;
|
5 | 4 | using Windows.ApplicationModel.Core;
|
6 | 5 | using Windows.Foundation;
|
7 | 6 | using Windows.Storage;
|
8 | 7 | using Windows.UI.Core.Preview;
|
9 | 8 | using Windows.UI.Xaml;
|
10 |
| -using Brainf_ckSharp.Enums; |
11 | 9 | using Brainf_ckSharp.Services;
|
12 |
| -using Brainf_ckSharp.Services.Uwp.Analytics; |
13 |
| -using Brainf_ckSharp.Services.Uwp.Email; |
14 |
| -using Brainf_ckSharp.Shared.Enums.Settings; |
15 | 10 | using Brainf_ckSharp.Uwp.Controls.Host;
|
16 | 11 | using Brainf_ckSharp.Uwp.Helpers;
|
17 |
| -using Brainf_ckSharp.Uwp.Services.Clipboard; |
18 | 12 | using Brainf_ckSharp.Uwp.Services.Files;
|
19 |
| -using Brainf_ckSharp.Uwp.Services.Keyboard; |
20 |
| -using Brainf_ckSharp.Uwp.Services.Settings; |
21 |
| -using Brainf_ckSharp.Uwp.Services.Share; |
22 |
| -using Brainf_ckSharp.Services.Uwp.Store; |
23 |
| -using Brainf_ckSharp.Services.Uwp.SystemInformation; |
24 | 13 | using Brainf_ckSharp.Shared.Constants;
|
25 |
| -using Brainf_ckSharp.Shared.ViewModels; |
26 |
| -using Brainf_ckSharp.Shared.ViewModels.Controls; |
27 |
| -using Brainf_ckSharp.Shared.ViewModels.Controls.SubPages; |
28 |
| -using Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings; |
29 | 14 | using Brainf_ckSharp.Shared.ViewModels.Views;
|
30 | 15 | using Brainf_ckSharp.Uwp.Controls.SubPages.Host;
|
31 |
| -using CommunityToolkit.Mvvm.Messaging; |
32 |
| -using GitHub; |
33 | 16 | using Microsoft.Extensions.DependencyInjection;
|
34 |
| -using Microsoft.Toolkit.Uwp.Helpers; |
35 | 17 | using Microsoft.Toolkit.Uwp.UI;
|
36 | 18 |
|
37 | 19 | #nullable enable
|
38 | 20 |
|
39 | 21 | namespace Brainf_ckSharp.Uwp;
|
40 | 22 |
|
41 |
| -/// <summary> |
42 |
| -/// Provides application-specific behavior to supplement the default <see cref="Application"/> class |
43 |
| -/// </summary> |
44 |
| -public sealed partial class App : Application |
| 23 | +/// <inheritdoc/> |
| 24 | +partial class App |
45 | 25 | {
|
46 | 26 | /// <summary>
|
47 | 27 | /// The currently requested file to open
|
@@ -158,7 +138,7 @@ private void OnActivated(bool prelaunchActivated)
|
158 | 138 | // Initialize the UI if needed
|
159 | 139 | if (Window.Current.Content is not Shell)
|
160 | 140 | {
|
161 |
| - InitializeServices(); |
| 141 | + InitializeServices(Services); |
162 | 142 |
|
163 | 143 | // Initial UI styling
|
164 | 144 | TitleBarHelper.ExpandViewIntoTitleBar();
|
@@ -207,71 +187,4 @@ private async void OnCloseRequested(object sender, SystemNavigationCloseRequeste
|
207 | 187 |
|
208 | 188 | deferral.Complete();
|
209 | 189 | }
|
210 |
| - |
211 |
| - /// <summary> |
212 |
| - /// Configures the services to use in the app |
213 |
| - /// </summary> |
214 |
| - /// <returns>An <see cref="IServiceProvider"/> instance with the app services.</returns> |
215 |
| - private IServiceProvider ConfigureServices() |
216 |
| - { |
217 |
| - ServiceCollection services = new(); |
218 |
| - |
219 |
| - // Prepare the app configuration |
220 |
| - services.AddSingleton(new AppConfiguration() { UnlockThemesIapId = "9P4Q63CCFPBM" }); |
221 |
| - |
222 |
| - // Services |
223 |
| - services.AddSingleton<IMessenger, StrongReferenceMessenger>(); |
224 |
| - services.AddSingleton<IFilesService, FilesService>(); |
225 |
| - services.AddSingleton<IFilesManagerService>(this); |
226 |
| - services.AddSingleton<ISettingsService, SettingsService>(); |
227 |
| - services.AddSingleton<IKeyboardListenerService, KeyboardListenerService>(); |
228 |
| - services.AddSingleton<IClipboardService, ClipboardService>(); |
229 |
| - services.AddSingleton<IShareService, ShareService>(); |
230 |
| - services.AddSingleton<IEmailService, EmailService>(); |
231 |
| - services.AddSingleton<ISystemInformationService, SystemInformationService>(); |
232 |
| - services.AddSingleton<IGitHubService>(_ => new GitHubService("Brainf_ckSharp|Uwp")); |
233 |
| -#if DEBUG |
234 |
| - services.AddSingleton<IStoreService, TestStoreService>(); |
235 |
| - services.AddSingleton<IAnalyticsService, TestAnalyticsService>(); |
236 |
| -#else |
237 |
| - services.AddSingleton<IStoreService, ProductionStoreService>(); |
238 |
| - services.AddSingleton<IAnalyticsService, ReleaseAnalyticsService>(); |
239 |
| -#endif |
240 |
| - |
241 |
| - // Viewmodels |
242 |
| - services.AddSingleton<ShellViewModel>(); |
243 |
| - services.AddSingleton<CompactMemoryViewerViewModel>(); |
244 |
| - services.AddSingleton<ConsoleViewModel>(); |
245 |
| - services.AddSingleton<IdeViewModel>(); |
246 |
| - services.AddSingleton<VirtualKeyboardViewModel>(); |
247 |
| - services.AddSingleton<StdinHeaderViewModel>(); |
248 |
| - services.AddSingleton<StatusBarViewModel>(); |
249 |
| - services.AddTransient<SettingsSubPageViewModel>(); |
250 |
| - services.AddTransient<ReviewPromptSubPageViewModel>(); |
251 |
| - services.AddTransient<IdeResultSubPageViewModel>(); |
252 |
| - services.AddTransient<CodeLibrarySubPageViewModel>(); |
253 |
| - services.AddTransient<AboutSubPageViewModel>(); |
254 |
| - |
255 |
| - return services.BuildServiceProvider(); |
256 |
| - } |
257 |
| - |
258 |
| - /// <summary> |
259 |
| - /// Performs additional settings configuration and other startup initialization |
260 |
| - /// </summary> |
261 |
| - private void InitializeServices() |
262 |
| - { |
263 |
| - ISettingsService settings = Services.GetRequiredService<ISettingsService>(); |
264 |
| - |
265 |
| - // Initialize default settings |
266 |
| - settings.SetValue(SettingsKeys.IsVirtualKeyboardEnabled, true, false); |
267 |
| - settings.SetValue(SettingsKeys.BracketsFormattingStyle, BracketsFormattingStyle.NewLine, false); |
268 |
| - settings.SetValue(SettingsKeys.IdeTheme, IdeTheme.VisualStudio, false); |
269 |
| - settings.SetValue(SettingsKeys.RenderWhitespaces, true, false); |
270 |
| - settings.SetValue(SettingsKeys.SelectedView, ViewType.Console, false); |
271 |
| - settings.SetValue(SettingsKeys.ClearStdinBufferOnRequest, false, false); |
272 |
| - settings.SetValue(SettingsKeys.ShowPBrainButtons, true, false); |
273 |
| - settings.SetValue(SettingsKeys.DataType, DataType.Byte, false); |
274 |
| - settings.SetValue(SettingsKeys.ExecutionOptions, ExecutionOptions.AllowOverflow, false); |
275 |
| - settings.SetValue(SettingsKeys.MemorySize, 128, false); |
276 |
| - } |
277 | 190 | }
|
0 commit comments