diff --git a/ProjBobcat/ProjBobcat/Class/Model/AssetObjectModel.cs b/ProjBobcat/ProjBobcat/Class/Model/AssetObjectModel.cs index 30d5305b..bef41558 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/AssetObjectModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/AssetObjectModel.cs @@ -30,7 +30,7 @@ public class AssetObjectModel /// Asset Objects集合 /// [JsonPropertyName("objects")] - public Dictionary Objects { get; set; } + public IReadOnlyDictionary Objects { get; set; } } [JsonSerializable(typeof(AssetObjectModel))] diff --git a/ProjBobcat/ProjBobcat/Class/Model/CurseForge/CurseForgeAddonInfo.cs b/ProjBobcat/ProjBobcat/Class/Model/CurseForge/CurseForgeAddonInfo.cs index ec7ce071..85605200 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/CurseForge/CurseForgeAddonInfo.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/CurseForge/CurseForgeAddonInfo.cs @@ -20,7 +20,7 @@ public class CurseForgeAddonInfo [JsonPropertyName("gameId")] public int GameId { get; set; } [JsonPropertyName("summary")] public string Summary { get; set; } - [JsonPropertyName("links")] public Dictionary Links { get; set; } + [JsonPropertyName("links")] public IReadOnlyDictionary Links { get; set; } [JsonPropertyName("defaultFileId")] public int DefaultFileId { get; set; } [JsonPropertyName("releaseType")] public int ReleaseType { get; set; } diff --git a/ProjBobcat/ProjBobcat/Class/Model/Fabric/FabricModInfoModel.cs b/ProjBobcat/ProjBobcat/Class/Model/Fabric/FabricModInfoModel.cs index 36293659..37eb2cd5 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Fabric/FabricModInfoModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Fabric/FabricModInfoModel.cs @@ -30,13 +30,13 @@ public class FabricModInfoModel [JsonPropertyName("environment")] public string Environment { get; set; } - [JsonPropertyName("entrypoints")] public Dictionary Entrypoints { get; set; } + [JsonPropertyName("entrypoints")] public IReadOnlyDictionary Entrypoints { get; set; } [JsonPropertyName("custom")] public Custom Custom { get; set; } - [JsonPropertyName("depends")] public Dictionary Depends { get; set; } + [JsonPropertyName("depends")] public IReadOnlyDictionary Depends { get; set; } - [JsonPropertyName("recommends")] public Dictionary Recommends { get; set; } + [JsonPropertyName("recommends")] public IReadOnlyDictionary Recommends { get; set; } [JsonPropertyName("name")] public string Name { get; set; } @@ -46,7 +46,7 @@ public class FabricModInfoModel [JsonPropertyName("authors")] public string[] Authors { get; set; } - [JsonPropertyName("contacts")] public Dictionary Contacts { get; set; } + [JsonPropertyName("contacts")] public IReadOnlyDictionary Contacts { get; set; } [JsonPropertyName("jars")] public FabricFileInfo[] Jars { get; set; } } diff --git a/ProjBobcat/ProjBobcat/Class/Model/Forge/ForgeInstallProfile.cs b/ProjBobcat/ProjBobcat/Class/Model/Forge/ForgeInstallProfile.cs index ff3f97b4..17ca8e63 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Forge/ForgeInstallProfile.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Forge/ForgeInstallProfile.cs @@ -20,7 +20,7 @@ public class ForgeInstallProfileProcessor [JsonPropertyName("args")] public string[] Arguments { get; set; } - [JsonPropertyName("outputs")] public Dictionary Outputs { get; set; } + [JsonPropertyName("outputs")] public IReadOnlyDictionary Outputs { get; set; } } public class ForgeInstallProfile @@ -45,7 +45,7 @@ public class ForgeInstallProfile [JsonPropertyName("welcome")] public string Welcome { get; set; } - [JsonPropertyName("data")] public Dictionary Data { get; set; } + [JsonPropertyName("data")] public IReadOnlyDictionary Data { get; set; } [JsonPropertyName("processors")] public ForgeInstallProfileProcessor[] Processors { get; set; } diff --git a/ProjBobcat/ProjBobcat/Class/Model/MicrosoftAuth/MojangProfileResponseModel.cs b/ProjBobcat/ProjBobcat/Class/Model/MicrosoftAuth/MojangProfileResponseModel.cs index 7fc72469..9f76ac57 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/MicrosoftAuth/MojangProfileResponseModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/MicrosoftAuth/MojangProfileResponseModel.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Text.Json; using System.Text.Json.Serialization; namespace ProjBobcat.Class.Model.MicrosoftAuth; diff --git a/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackFileModel.cs b/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackFileModel.cs index 1d2f369f..e04f1fc9 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackFileModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackFileModel.cs @@ -7,7 +7,7 @@ public class ModrinthModPackFileModel { [JsonPropertyName("path")] public string? Path { get; set; } - [JsonPropertyName("hashes")] public Dictionary Hashes { get; set; } + [JsonPropertyName("hashes")] public IReadOnlyDictionary Hashes { get; set; } [JsonPropertyName("downloads")] public string[] Downloads { get; set; } diff --git a/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackIndexModel.cs b/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackIndexModel.cs index a2c06727..03b8a3f5 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackIndexModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthModPackIndexModel.cs @@ -17,7 +17,7 @@ public class ModrinthModPackIndexModel [JsonPropertyName("files")] public ModrinthModPackFileModel[] Files { get; set; } - [JsonPropertyName("dependencies")] public Dictionary Dependencies { get; set; } + [JsonPropertyName("dependencies")] public IReadOnlyDictionary Dependencies { get; set; } } [JsonSerializable(typeof(ModrinthModPackIndexModel))] diff --git a/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthVersionInfo.cs b/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthVersionInfo.cs index 07b1b0fc..e223911a 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthVersionInfo.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Modrinth/ModrinthVersionInfo.cs @@ -6,7 +6,7 @@ namespace ProjBobcat.Class.Model.Modrinth; public class ModrinthFileInfo { - [JsonPropertyName("hashes")] public Dictionary Hashes { get; set; } + [JsonPropertyName("hashes")] public IReadOnlyDictionary Hashes { get; set; } [JsonPropertyName("url")] public string Url { get; set; } diff --git a/ProjBobcat/ProjBobcat/Class/Model/Mojang/UserProfilePropertyValue.cs b/ProjBobcat/ProjBobcat/Class/Model/Mojang/UserProfilePropertyValue.cs index a073b4c7..cd18c7ff 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Mojang/UserProfilePropertyValue.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Mojang/UserProfilePropertyValue.cs @@ -13,7 +13,7 @@ public class UserProfilePropertyValue [JsonPropertyName("timestamp")] public long Timestamp { get; set; } [JsonPropertyName("profileId")] public string ProfileId { get; set; } [JsonPropertyName("profileName")] public string ProfileName { get; set; } - [JsonPropertyName("textures")] public Dictionary Textures { get; set; } + [JsonPropertyName("textures")] public IReadOnlyDictionary Textures { get; set; } } [JsonSerializable(typeof(UserProfilePropertyValue))] diff --git a/ProjBobcat/ProjBobcat/Class/Model/RawVersionModel.cs b/ProjBobcat/ProjBobcat/Class/Model/RawVersionModel.cs index f72ef54c..021a90d3 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/RawVersionModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/RawVersionModel.cs @@ -75,7 +75,7 @@ public class Extract public class Downloads { [JsonPropertyName("artifact")] public FileInfo? Artifact { get; set; } - [JsonPropertyName("classifiers")] public Dictionary Classifiers { get; set; } + [JsonPropertyName("classifiers")] public IReadOnlyDictionary Classifiers { get; set; } } public class Library @@ -86,7 +86,7 @@ public class Library [JsonPropertyName("extract")] public Extract Extract { get; set; } - [JsonPropertyName("natives")] public Dictionary Natives { get; set; } + [JsonPropertyName("natives")] public IReadOnlyDictionary Natives { get; set; } [JsonPropertyName("rules")] public JvmRules[] Rules { get; set; } diff --git a/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/PlayerTextureInfoModel.cs b/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/PlayerTextureInfoModel.cs index 43649b09..d30fe109 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/PlayerTextureInfoModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/PlayerTextureInfoModel.cs @@ -11,5 +11,5 @@ public class PlayerTextureInfoModel [JsonPropertyName("profileName")] public string ProfileName { get; set; } - [JsonPropertyName("textures")] public Dictionary Textures { get; set; } + [JsonPropertyName("textures")] public IReadOnlyDictionary Textures { get; set; } } \ No newline at end of file diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs b/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs index f86817b5..75f29c33 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs @@ -121,6 +121,7 @@ public event EventHandler DownloadFileCompletedE async Task ReceiveGameResourceTask(IAsyncEnumerable asyncEnumerable) { var count = 0UL; + var refreshCounter = 0; await foreach (var element in asyncEnumerable) { @@ -133,6 +134,13 @@ async Task ReceiveGameResourceTask(IAsyncEnumerable asyncEnumerab }); await gameResourceTransBlock.SendAsync(element); + refreshCounter++; + + if (refreshCounter % 10 == 0) + { + Interlocked.Add(ref _needToDownload, count); + count = 0; + } } Interlocked.Add(ref _needToDownload, count); @@ -141,7 +149,7 @@ async Task ReceiveGameResourceTask(IAsyncEnumerable asyncEnumerab var chunks = ResourceInfoResolvers.Chunk(MaxDegreeOfParallelism).ToImmutableArray(); foreach (var chunk in chunks) { - var tasks = new Task[chunk.Length]; + var tasks = new Task[chunk.Length * 2]; for (var i = 0; i < chunk.Length; i++) {