code style

This commit is contained in:
Lightczx
2024-02-05 17:25:59 +08:00
parent e5677e7de4
commit 40b26d9d3c
2 changed files with 8 additions and 10 deletions

View File

@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using CommunityToolkit.WinUI.Notifications;
using Microsoft.Web.WebView2.Core;
using Microsoft.Win32;
using Snap.Hutao.Core.Setting;
@@ -9,6 +8,7 @@ using System.IO;
using System.Security.Principal;
using Windows.ApplicationModel;
using Windows.Storage;
using Windows.UI.Notifications;
namespace Snap.Hutao.Core;
@@ -88,7 +88,7 @@ internal sealed class RuntimeOptions
private bool isToastAvailable;
private bool isToastAvailableInitialized;
private object locker = new();
private object isToastAvailableLock = new();
public RuntimeOptions(IServiceProvider serviceProvider, ILogger<RuntimeOptions> logger)
{
@@ -121,13 +121,13 @@ internal sealed class RuntimeOptions
{
get
{
return LazyInitializer.EnsureInitialized(ref isToastAvailable, ref isToastAvailableInitialized, ref locker, () =>
return LazyInitializer.EnsureInitialized(ref isToastAvailable, ref isToastAvailableInitialized, ref isToastAvailableLock, GetIsToastAvailable);
bool GetIsToastAvailable()
{
return serviceProvider.GetRequiredService<ITaskContext>().InvokeOnMainThread(() =>
{
return ToastNotificationManagerCompat.CreateToastNotifier().Setting is Windows.UI.Notifications.NotificationSetting.Enabled;
});
});
ITaskContext taskContext = serviceProvider.GetRequiredService<ITaskContext>();
return taskContext.InvokeOnMainThread(() => ToastNotificationManager.CreateToastNotifier().Setting is NotificationSetting.Enabled);
}
}
}

View File

@@ -7,8 +7,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
xmlns:mxic="using:Microsoft.Xaml.Interactions.Core"
xmlns:mxim="using:Microsoft.Xaml.Interactions.Media"
xmlns:shc="using:Snap.Hutao.Control"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shch="using:Snap.Hutao.Control.Helper"