Revert "File scoped namespaces"

This reverts commit d31d8f574e.
This commit is contained in:
Burak Kaan Köse
2025-02-16 11:43:30 +01:00
parent d31d8f574e
commit cf9869b71e
617 changed files with 32097 additions and 31478 deletions

View File

@@ -5,58 +5,59 @@ using Serilog;
using Windows.ApplicationModel.Background;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.UWP.Services;
public class BackgroundTaskService : IBackgroundTaskService
namespace Wino.Core.UWP.Services
{
private const string IsBackgroundTasksUnregisteredKey = nameof(IsBackgroundTasksUnregisteredKey);
public const string ToastNotificationActivationHandlerTaskName = "ToastNotificationActivationHandlerTask";
private readonly IConfigurationService _configurationService;
public BackgroundTaskService(IConfigurationService configurationService)
public class BackgroundTaskService : IBackgroundTaskService
{
_configurationService = configurationService;
}
private const string IsBackgroundTasksUnregisteredKey = nameof(IsBackgroundTasksUnregisteredKey);
public const string ToastNotificationActivationHandlerTaskName = "ToastNotificationActivationHandlerTask";
public void UnregisterAllBackgroundTask()
{
if (_configurationService.Get(IsBackgroundTasksUnregisteredKey, false))
private readonly IConfigurationService _configurationService;
public BackgroundTaskService(IConfigurationService configurationService)
{
foreach (var task in BackgroundTaskRegistration.AllTasks)
{
task.Value.Unregister(true);
}
_configurationService = configurationService;
}
Log.Information("Unregistered all background tasks.");
_configurationService.Set(IsBackgroundTasksUnregisteredKey, true);
public void UnregisterAllBackgroundTask()
{
if (_configurationService.Get(IsBackgroundTasksUnregisteredKey, false))
{
foreach (var task in BackgroundTaskRegistration.AllTasks)
{
task.Value.Unregister(true);
}
Log.Information("Unregistered all background tasks.");
_configurationService.Set(IsBackgroundTasksUnregisteredKey, true);
}
}
public Task RegisterBackgroundTasksAsync()
{
return RegisterToastNotificationHandlerBackgroundTaskAsync();
}
public async Task RegisterToastNotificationHandlerBackgroundTaskAsync()
{
// If background task is already registered, do nothing.
if (BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(ToastNotificationActivationHandlerTaskName)))
return;
// Otherwise request access
BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();
// Create the background task
BackgroundTaskBuilder builder = new BackgroundTaskBuilder()
{
Name = ToastNotificationActivationHandlerTaskName
};
// Assign the toast action trigger
builder.SetTrigger(new ToastNotificationActionTrigger());
// And register the task
BackgroundTaskRegistration registration = builder.Register();
}
}
public Task RegisterBackgroundTasksAsync()
{
return RegisterToastNotificationHandlerBackgroundTaskAsync();
}
public async Task RegisterToastNotificationHandlerBackgroundTaskAsync()
{
// If background task is already registered, do nothing.
if (BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(ToastNotificationActivationHandlerTaskName)))
return;
// Otherwise request access
BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();
// Create the background task
BackgroundTaskBuilder builder = new BackgroundTaskBuilder()
{
Name = ToastNotificationActivationHandlerTaskName
};
// Assign the toast action trigger
builder.SetTrigger(new ToastNotificationActionTrigger());
// And register the task
BackgroundTaskRegistration registration = builder.Register();
}
}