Skip to content

Commit 4531bd0

Browse files
authored
Merge pull request PCL-Community#77 from 9223372036854775807-Studio/main
refactor: 将部分代码移动到 PCL.Neo.Core
2 parents 2c06356 + c36e4b0 commit 4531bd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+168
-604
lines changed

.run/LinuxPublish.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="LinuxPublish" type="DotNetFolderPublish" factoryName="Publish to folder">
3+
<riderPublish configuration="Release" include_all_content_for_self_extract="true" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="linux-x64" self_contained="true" target_folder="$PROJECT_DIR$/PCL.Neo/bin/Release/net9.0/linux-x64/publish" target_framework="net9.0" trim_unused_assemblies="true" uuid_high="-7633829966872318734" uuid_low="5995717239141094893" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

.run/MacOSPublish.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="MacOSPublish" type="DotNetFolderPublish" factoryName="Publish to folder">
3+
<riderPublish configuration="Release" include_all_content_for_self_extract="true" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="osx-x64" self_contained="true" target_folder="$PROJECT_DIR$/PCL.Neo/bin/Release/net9.0/osx-x64/publish" target_framework="net9.0" trim_unused_assemblies="true" uuid_high="-7633829966872318734" uuid_low="5995717239141094893" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

.run/WinPublish.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="WinPublish" type="DotNetFolderPublish" factoryName="Publish to folder">
3+
<riderPublish configuration="Release" include_all_content_for_self_extract="true" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="osx-x64" self_contained="true" target_folder="$PROJECT_DIR$/PCL2.Neo/bin/Release/net9.0/osx-x64/publish" target_framework="net9.0" trim_unused_assemblies="true" uuid_high="-7633829966872318734" uuid_low="5995717239141094893" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

PCL.Neo.Core/Const.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System.Runtime.InteropServices;
2+
3+
namespace PCL.Neo.Core;
4+
5+
public static class Const
6+
{
7+
/// <summary>
8+
/// 系统是否为64位。
9+
/// </summary>
10+
public static readonly bool Is64Os = Environment.Is64BitOperatingSystem;
11+
public enum RunningOs
12+
{
13+
Windows,
14+
Linux,
15+
MacOs,
16+
Unknown
17+
}
18+
19+
public static readonly RunningOs Os = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
20+
? RunningOs.Windows
21+
: RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
22+
? RunningOs.Linux
23+
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
24+
? RunningOs.MacOs
25+
: RunningOs.Unknown;
26+
27+
public static readonly Architecture Architecture = RuntimeInformation.ProcessArchitecture;
28+
29+
/// <summary>
30+
/// 根据 MOJANG API 命名
31+
/// </summary>
32+
public static string Platform
33+
{
34+
get
35+
{
36+
return Os switch
37+
{
38+
RunningOs.Windows => Architecture switch
39+
{
40+
Architecture.X64 => "windows-x64",
41+
Architecture.X86 => "windows-x86",
42+
Architecture.Arm64 => "windows-arm64",
43+
_ => "unknown"
44+
},
45+
RunningOs.Linux => Architecture switch
46+
{
47+
Architecture.X64 => "linux",
48+
Architecture.X86 => "linux-i386",
49+
_ => "unknown"
50+
},
51+
RunningOs.MacOs => Architecture switch
52+
{
53+
Architecture.X64 => "mac-os",
54+
Architecture.Arm64 => "mac-os-arm64",
55+
_ => "unknown"
56+
},
57+
RunningOs.Unknown => "unknown",
58+
_ => "unknown"
59+
};
60+
}
61+
}
62+
}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
using Avalonia.Platform.Storage;
2-
using CommunityToolkit.Mvvm.DependencyInjection;
3-
using PCL.Neo.Services;
4-
using System;
51
using System.Diagnostics;
6-
using System.IO;
7-
using System.Net.Http;
82
using System.Runtime.InteropServices;
93
using System.Runtime.Versioning;
10-
using System.Threading;
11-
using System.Threading.Tasks;
124

13-
namespace PCL.Neo.Helpers;
5+
namespace PCL.Neo.Core.Helpers;
146

157
/// <summary>
168
/// 一些文件操作和下载请求之类的
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace PCL.Neo.Models.Audio
1+
namespace PCL.Neo.Core.Models.Audio
82
{
93
public enum FileType
104
{

PCL.Neo/Models/Audio/AudioFileSearcher.cs renamed to PCL.Neo.Core/Models/Audio/AudioFileSearcher.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
6-
namespace PCL.Neo.Models.Audio
1+
namespace PCL.Neo.Core.Models.Audio
72
{
83
public class AudioFileSearcher
94
{

PCL.Neo/Models/Minecraft/AssetIndexFile.cs renamed to PCL.Neo.Core/Models/Minecraft/AssetIndexFile.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Text.Json;
42
using System.Text.Json.Nodes;
53
using System.Text.Json.Serialization;
64

7-
namespace PCL.Neo.Models.Minecraft;
5+
namespace PCL.Neo.Core.Models.Minecraft;
86

97
public class AssetIndexFile
108
{

PCL.Neo/Models/Minecraft/Game/Data/Arguments.cs renamed to PCL.Neo.Core/Models/Minecraft/Game/Data/Arguments.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
41
using System.Text.RegularExpressions;
5-
using static PCL.Neo.Models.Minecraft.MetadataFile.Rule;
2+
using static PCL.Neo.Core.Models.Minecraft.MetadataFile.Rule;
63

7-
namespace PCL.Neo.Models.Minecraft.Game.Data
4+
namespace PCL.Neo.Core.Models.Minecraft.Game.Data
85
{
96
public partial class Arguments
107
{

PCL.Neo/Models/Minecraft/Game/Data/GameEntity.cs renamed to PCL.Neo.Core/Models/Minecraft/Game/Data/GameEntity.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Diagnostics;
2-
using System.IO;
32

4-
namespace PCL.Neo.Models.Minecraft.Game.Data;
3+
namespace PCL.Neo.Core.Models.Minecraft.Game.Data;
54

65
public record GameEntityInfo
76
{

0 commit comments

Comments
 (0)