Skip to content

Commit

Permalink
reduce using statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Nov 11, 2022
1 parent aac1e62 commit a66a0b8
Show file tree
Hide file tree
Showing 40 changed files with 30 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.UI.Xaml.Media;
using Snap.Hutao.Core;
using Snap.Hutao.Core.Caching;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Extension;
using Snap.Hutao.Service.Abstraction;
using System.Net.Http;
Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Core/Caching/CacheBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using Snap.Hutao.Core.Logging;
using Snap.Hutao.Core.Threading;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
Expand Down
2 changes: 0 additions & 2 deletions src/Snap.Hutao/Snap.Hutao/Core/CoreEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using Microsoft.Win32;
using Snap.Hutao.Core.Convert;
using Snap.Hutao.Extension;
using System.Security.Cryptography;
using System.Text;
using System.Text.Encodings.Web;
using Windows.ApplicationModel;

Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Core/Database/DbSetExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Snap.Hutao.Model.Entity;

namespace Snap.Hutao.Core.Database;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using Windows.ApplicationModel.DataTransfer;

namespace Snap.Hutao.Core.IO.DataTransfer;
Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Core/IO/StorageFileExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using System.IO;
using Windows.Storage;

Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Core/Logging/LogEntryQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.EntityFrameworkCore;
using Snap.Hutao.Context.Database;
using Snap.Hutao.Context.FileSystem;
using Snap.Hutao.Core.Threading;
using System.Collections.Concurrent;
using System.Diagnostics;

Expand Down
34 changes: 22 additions & 12 deletions src/Snap.Hutao/Snap.Hutao/Core/TaskSchedulerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,32 @@ internal static class TaskSchedulerHelper
/// 注册实时便笺刷新任务
/// </summary>
/// <param name="interval">间隔(秒)</param>
public static void RegisterForDailyNoteRefresh(int interval)
/// <returns>是否注册或修改成功</returns>
public static bool RegisterForDailyNoteRefresh(int interval)
{
TimeSpan intervalTime = TimeSpan.FromSeconds(interval);
if (TaskService.Instance.GetTask(DailyNoteRefreshTaskName) is SchedulerTask targetTask)
try
{
TimeTrigger? trigger = targetTask.Definition.Triggers[0] as TimeTrigger;
trigger!.Repetition.Interval = intervalTime;
targetTask.RegisterChanges();
TimeSpan intervalTime = TimeSpan.FromSeconds(interval);
if (TaskService.Instance.GetTask(DailyNoteRefreshTaskName) is SchedulerTask targetTask)
{
TimeTrigger? trigger = targetTask.Definition.Triggers[0] as TimeTrigger;
trigger!.Repetition.Interval = intervalTime;
targetTask.RegisterChanges();
return true;
}
else
{
TaskDefinition task = TaskService.Instance.NewTask();
task.RegistrationInfo.Description = "胡桃实时便笺刷新任务 | 请勿编辑或删除。";
task.Triggers.Add(new TimeTrigger() { Repetition = new(intervalTime, TimeSpan.Zero), });
task.Actions.Add("explorer", "hutao://DailyNote/Refresh");
TaskService.Instance.RootFolder.RegisterTaskDefinition(DailyNoteRefreshTaskName, task);
return true;
}
}
else
catch (UnauthorizedAccessException)
{
TaskDefinition task = TaskService.Instance.NewTask();
task.RegistrationInfo.Description = "胡桃实时便笺刷新任务 | 请勿编辑或删除。";
task.Triggers.Add(new TimeTrigger() { Repetition = new(intervalTime, TimeSpan.Zero), });
task.Actions.Add("explorer", "hutao://DailyNote/Refresh");
TaskService.Instance.RootFolder.RegisterTaskDefinition(DailyNoteRefreshTaskName, task);
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public CancellationTokenTaskCompletionSource(CancellationToken cancellationToken
return;
}

var tcs = new TaskCompletionSource();
TaskCompletionSource tcs = new TaskCompletionSource();
registration = cancellationToken.Register(() => tcs.TrySetResult(), useSynchronizationContext: false);
Task = tcs.Task;
}
Expand Down
2 changes: 0 additions & 2 deletions src/Snap.Hutao/Snap.Hutao/Model/NamedValue.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using CommunityToolkit.Mvvm.ComponentModel;

namespace Snap.Hutao.Model;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Snap.Hutao.Core.Database;
using Snap.Hutao.Core.Diagnostics;
using Snap.Hutao.Core.Logging;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Model.InterChange.Achievement;
using System.Collections.ObjectModel;
using BindingAchievement = Snap.Hutao.Model.Binding.Achievement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Snap.Hutao.Core.Database;
using Snap.Hutao.Core.Diagnostics;
using Snap.Hutao.Core.Logging;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Model.Binding.AvatarProperty;
using Snap.Hutao.Model.Metadata;
using Snap.Hutao.Service.AvatarInfo.Factory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using Snap.Hutao.Model.Binding.AvatarProperty;
using Snap.Hutao.Web.Hoyolab;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void RemoveDailyNote(DailyNoteEntry entry)
}
}

private async ValueTask NotifyDailyNoteAsync(BindingClient client,DailyNoteEntry entry)
private async ValueTask NotifyDailyNoteAsync(BindingClient client, DailyNoteEntry entry)
{
if (entry.DailyNote == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Snap.Hutao.Core.Database;
using Snap.Hutao.Core.Diagnostics;
using Snap.Hutao.Core.Logging;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Extension;
using Snap.Hutao.Model.Binding.Gacha;
using Snap.Hutao.Model.Binding.Gacha.Abstraction;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using Snap.Hutao.View.Dialog;

namespace Snap.Hutao.Service.GachaLog;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using Snap.Hutao.Service.User;
using Snap.Hutao.Web.Hoyolab;
using Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the MIT license.

using Snap.Hutao.Core.IO;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Extension;
using Snap.Hutao.Service.Game;
using System.IO;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using Snap.Hutao.Core.Abstraction;
using Snap.Hutao.Core.Threading;

namespace Snap.Hutao.Service.GachaLog;

Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Snap.Hutao.Core;
using Snap.Hutao.Core.Database;
using Snap.Hutao.Core.IO.Ini;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Model.Binding.LaunchGame;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Game.Locator;
Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/Service/Game/IGameService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using Snap.Hutao.Model.Binding.LaunchGame;
using Snap.Hutao.Model.Entity;
using System.Collections.ObjectModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using Snap.Hutao.Core.Abstraction;
using Snap.Hutao.Core.Threading;

namespace Snap.Hutao.Service.Game.Locator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Core.Threading;
using Snap.Hutao.Factory.Abstraction;
using Windows.Storage;
using Windows.Storage.Pickers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.Win32;
using Snap.Hutao.Core.IO.Ini;
using Snap.Hutao.Core.Threading;
using System.IO;
using System.Text.RegularExpressions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public BottomTextControl()
/// </summary>
public UIElement TopContent
{
get { return (UIElement)GetValue(TopContentProperty); }
set { SetValue(TopContentProperty, value); }
get => (UIElement)GetValue(TopContentProperty);
set => SetValue(TopContentProperty, value);
}

/// <summary>
/// 文本
/// </summary>
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}

private static void OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Core.Threading;

namespace Snap.Hutao.View.Dialog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Core;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Model.InterChange.Achievement;
using Snap.Hutao.Service.Achievement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,7 @@

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Snap.Hutao.Model.Entity;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

namespace Snap.Hutao.View.Dialog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Core.Threading;

namespace Snap.Hutao.View.Dialog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Core.Threading;

namespace Snap.Hutao.View.Dialog;

Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/View/Dialog/UserDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Core.Threading;

namespace Snap.Hutao.View.Dialog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.UI.Xaml.Navigation;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Core;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Service.Navigation;
using Windows.System;

Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/View/Page/DailyNotePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<AppBarButton.Flyout>
<Flyout Placement="BottomEdgeAlignedRight">
<StackPanel>
<RadioButtons ItemsSource="{Binding RefreshTimes}" SelectedItem="{Binding SelectedRefreshTime}">
<RadioButtons ItemsSource="{Binding RefreshTimes}" SelectedItem="{Binding SelectedRefreshTime,Mode=TwoWay}">
<RadioButtons.Header>
<TextBlock Text="刷新间隔时间" Style="{StaticResource BaseTextBlockStyle}"/>
</RadioButtons.Header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.UI.Xaml;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.Navigation;
using Snap.Hutao.Service.User;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.UI.Xaml;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.Navigation;
using Snap.Hutao.Service.User;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using CommunityToolkit.Mvvm.ComponentModel;
using Snap.Hutao.Control;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model.Binding.AvatarProperty;
using Snap.Hutao.Model.Binding.User;
Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Snap.Hutao.Control;
using Snap.Hutao.Control.Extension;
using Snap.Hutao.Core.IO;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Core.Threading.CodeAnalysis;
using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model.Binding.Gacha;
Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/ViewModel/UserViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Snap.Hutao.Core.IO.DataTransfer;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model.Binding.User;
using Snap.Hutao.Service.Abstraction;
Expand Down
1 change: 0 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/ViewModel/WikiAvatarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.WinUI.UI;
using Snap.Hutao.Core.Threading;
using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model;
using Snap.Hutao.Model.Binding.Hutao;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ public class RecoveryTime
[JsonIgnore]
public int TotalSeconds
{
get
{
return (60 * 60 * 24 * 7) - (Second + (60 * Minute) + (60 * 60 * Hour) + (60 * 60 * 24 * Day));
}
get => (60 * 60 * 24 * 7) - (Second + (60 * Minute) + (60 * 60 * Hour) + (60 * 60 * 24 * Day));
}

/// <summary>
Expand Down

0 comments on commit a66a0b8

Please sign in to comment.