From 3f2876a64680e242ef6a68dda656eb5b58e8e0b7 Mon Sep 17 00:00:00 2001 From: Aetopia <41850963+Aetopia@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:53:40 +0530 Subject: [PATCH] Remove boilerplate. --- src/BedrockUpdater.csproj | 2 +- src/Store.cs | 21 ++++----------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/BedrockUpdater.csproj b/src/BedrockUpdater.csproj index 8f00097..92e51a0 100644 --- a/src/BedrockUpdater.csproj +++ b/src/BedrockUpdater.csproj @@ -12,7 +12,7 @@ Resources/.manifest Resources/.ico - 1.1.6.1 + 1.1.6.2 Bedrock Updater Bedrock Updater Copyright (C) 2024 diff --git a/src/Store.cs b/src/Store.cs index 887e280..8cc6b51 100644 --- a/src/Store.cs +++ b/src/Store.cs @@ -52,15 +52,9 @@ static class Store static readonly WebClient client = new() { BaseAddress = "https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/" }; - static readonly (string, string) runtime = ( - RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(), - RuntimeInformation.OSArchitecture switch { Architecture.X64 => "x86", Architecture.Arm64 => "arm", _ => null } - ); + static readonly (string, string) runtime = (RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(), RuntimeInformation.OSArchitecture switch { Architecture.X64 => "x86", Architecture.Arm64 => "arm", _ => null }); - static readonly (ProcessorArchitecture, ProcessorArchitecture) processor = ( - GetArchitecture(runtime.Item1), - GetArchitecture(runtime.Item2) - ); + static readonly (ProcessorArchitecture, ProcessorArchitecture) processor = (GetProcessorArchitecture(runtime.Item1), GetProcessorArchitecture(runtime.Item2)); static string data; @@ -113,14 +107,7 @@ internal static ReadOnlyCollection GetUpdates(Product product) var identity = file.Attributes["InstallerSpecificIdentifier"].InnerText.Split('_'); var neutral = identity[2] == "neutral"; if (!neutral && identity[2] != runtime.Item1 && identity[2] != runtime.Item2) continue; - if ((architecture = (neutral ? product.Architecture : identity[2]) switch - { - "x86" => ProcessorArchitecture.X86, - "x64" => ProcessorArchitecture.X64, - "arm" => ProcessorArchitecture.Arm, - "arm64" => ProcessorArchitecture.Arm64, - _ => ProcessorArchitecture.Unknown - }) == ProcessorArchitecture.Unknown) return null; + if ((architecture = GetProcessorArchitecture(neutral ? product.Architecture : identity[2])) == ProcessorArchitecture.Unknown) return null; var key = $"{identity[0]}_{identity[2]}"; if (!dictionary.ContainsKey(key)) dictionary.Add(key, new() @@ -163,7 +150,7 @@ internal static ReadOnlyCollection GetUpdates(Product product) return updates.AsReadOnly(); } - static ProcessorArchitecture GetArchitecture(string architecture) => architecture switch + static ProcessorArchitecture GetProcessorArchitecture(string architecture) => architecture switch { "x86" => ProcessorArchitecture.X86, "x64" => ProcessorArchitecture.X64,