Skip to content

Commit b796dfe

Browse files
committed
chore: 清理代码
1 parent 55455f4 commit b796dfe

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

DotVast.HashTool.WinUI/Helpers/RuntimeHelper.cs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,17 @@
1-
using System.Reflection;
2-
using System.Runtime.InteropServices;
3-
using System.Text;
4-
51
using Windows.ApplicationModel;
62

73
namespace DotVast.HashTool.WinUI.Helpers;
84

95
public sealed class RuntimeHelper
106
{
11-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
12-
private static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder? packageFullName);
13-
14-
#region IsMSIX
15-
16-
private static bool? s_isMSIX;
17-
public static bool IsMSIX => s_isMSIX ??= GetIsMSIX();
18-
private static bool GetIsMSIX()
19-
{
20-
var length = 0;
21-
return GetCurrentPackageFullName(ref length, null) != 15700L;
22-
}
23-
24-
#endregion IsMSIX
25-
267
#region AppVersion
278

289
private static Version? s_appVersion;
2910
public static Version AppVersion => s_appVersion ??= GetAppVersion();
3011
private static Version GetAppVersion()
3112
{
32-
if (IsMSIX)
33-
{
34-
var packageVersion = Package.Current.Id.Version;
35-
// 使用语义化版本
36-
s_appVersion = new(packageVersion.Major, packageVersion.Minor, packageVersion.Build);
37-
}
38-
else
39-
{
40-
s_appVersion = Assembly.GetExecutingAssembly().GetName().Version!;
41-
}
42-
43-
return s_appVersion;
13+
var packageVersion = Package.Current.Id.Version;
14+
return new(packageVersion.Major, packageVersion.Minor, packageVersion.Build); // 使用语义化版本
4415
}
4516

4617
#endregion AppVersion

DotVast.HashTool.WinUI/Services/CheckUpdateService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
using Microsoft.Extensions.Logging;
1010

11-
using Windows.ApplicationModel;
12-
1311
namespace DotVast.HashTool.WinUI.Services;
1412

1513
internal partial class CheckUpdateService : ICheckUpdateService

0 commit comments

Comments
 (0)