mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-29 07:27:36 +08:00
update readme.md migrate V2 1%
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System.IO;
|
||||
|
||||
namespace System.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// 适用于桌面端的文件系统帮助类,参考 Xamarin.Essentials.FileSystem
|
||||
/// <para><see cref="https://docs.microsoft.com/zh-cn/xamarin/essentials/file-system-helpers?tabs=uwp"/></para>
|
||||
/// </summary>
|
||||
public class FileSystemDesktop
|
||||
{
|
||||
const string AppDataDirName = "AppData";
|
||||
const string CacheDirName = "Cache";
|
||||
|
||||
/// <summary>
|
||||
/// 初始化文件系统
|
||||
/// </summary>
|
||||
public static void InitFileSystem()
|
||||
{
|
||||
var appDataRootPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
if (string.IsNullOrWhiteSpace(appDataRootPath))
|
||||
{
|
||||
// 需要测试 macOS 和 linux 上 Environment.SpecialFolder.ApplicationData 返回的目录值
|
||||
// 之前在 android 上测试过 Environment.GetFolderPath 有些枚举值返回的是空字符串 比如StartMenu
|
||||
throw new ArgumentNullException(nameof(appDataRootPath));
|
||||
}
|
||||
appDataRootPath = Path.Combine(appDataRootPath, BuildConfig.APPLICATION_ID);
|
||||
var appDataPath = Path.Combine(appDataRootPath, AppDataDirName);
|
||||
var cachePath = Path.Combine(appDataRootPath, CacheDirName);
|
||||
IOPath.DirCreateByNotExists(appDataPath);
|
||||
IOPath.DirCreateByNotExists(cachePath);
|
||||
IOPath.InitFileSystem(GetAppDataDirectory, GetCacheDirectory);
|
||||
string GetAppDataDirectory() => appDataPath;
|
||||
string GetCacheDirectory() => cachePath;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Xamarin.Essentials.FileSystem.AppDataDirectory"/>
|
||||
[Obsolete("use IOPath.AppDataDirectory", true)]
|
||||
public static string AppDataDirectory => IOPath.AppDataDirectory;
|
||||
|
||||
/// <inheritdoc cref="Xamarin.Essentials.FileSystem.CacheDirectory"/>
|
||||
[Obsolete("use IOPath.CacheDirectory", true)]
|
||||
public static string CacheDirectory => IOPath.CacheDirectory;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace System.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// 适用于桌面端的主线程帮助类,参考 Xamarin.Essentials.MainThread
|
||||
/// <para><see cref="https://docs.microsoft.com/zh-cn/xamarin/essentials/main-thread"/></para>
|
||||
/// <para><see cref="https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/MainThread/MainThread.shared.cs"/></para>
|
||||
/// </summary>
|
||||
public static class MainThreadDesktop
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Application.Services;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System.Application.Services;
|
||||
using System.Application.Services.Implementation;
|
||||
using System.Application.UI.ViewModels;
|
||||
using System.Security;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
|
||||
+5
@@ -16,6 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\System.Application.Repositories.sqlite-net-pcl\System.Application.Repositories.sqlite-net-pcl.csproj" />
|
||||
<ProjectReference Include="..\System.Application.SteamTools.Client.Desktop.Platform\System.Application.SteamTools.Client.Desktop.Platform.csproj" />
|
||||
<ProjectReference Include="..\System.Application.SteamTools.Client\System.Application.SteamTools.Client.csproj" />
|
||||
</ItemGroup>
|
||||
@@ -35,4 +36,8 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Entities\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace System.Application.UI
|
||||
{
|
||||
public static class AppHelper
|
||||
{
|
||||
static AppHelper()
|
||||
{
|
||||
var mainModule = Process.GetCurrentProcess().MainModule;
|
||||
if (mainModule == null)
|
||||
throw new ArgumentNullException(nameof(mainModule));
|
||||
var fullName = mainModule.FileName;
|
||||
if (fullName == null)
|
||||
throw new ArgumentNullException(nameof(fullName));
|
||||
var programName = Path.GetFileName(fullName);
|
||||
if (programName == null)
|
||||
throw new ArgumentNullException(nameof(programName));
|
||||
ProgramName = programName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前主程序文件名,例如word.exe
|
||||
/// </summary>
|
||||
public static string ProgramName { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user