Skip to content

Commit

Permalink
Remove boilerplate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aetopia committed Jul 9, 2024
1 parent 6b61d82 commit 3f2876a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/BedrockUpdater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ApplicationManifest>Resources/.manifest</ApplicationManifest>
<ApplicationIcon>Resources/.ico</ApplicationIcon>

<AssemblyVersion>1.1.6.1</AssemblyVersion>
<AssemblyVersion>1.1.6.2</AssemblyVersion>
<AssemblyTitle>Bedrock Updater</AssemblyTitle>
<Product>Bedrock Updater</Product>
<Copyright>Copyright (C) 2024</Copyright>
Expand Down
21 changes: 4 additions & 17 deletions src/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -113,14 +107,7 @@ internal static ReadOnlyCollection<UpdateIdentity> 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()
Expand Down Expand Up @@ -163,7 +150,7 @@ internal static ReadOnlyCollection<UpdateIdentity> 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,
Expand Down

0 comments on commit 3f2876a

Please sign in to comment.