Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit 88b1ee7

Browse files
committed
Default to x64 architecture
1 parent 2be10d0 commit 88b1ee7

4 files changed

Lines changed: 19 additions & 24 deletions

File tree

OpenTabletDriver.Web.Core/Framework/DotnetCoreService.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using System;
2-
using System.Data.SqlTypes;
3-
using System.Diagnostics;
4-
using System.IO;
5-
using System.Net.Http;
6-
using System.Threading.Tasks;
72
using OpenTabletDriver.Web.Core.Services;
83

94
namespace OpenTabletDriver.Web.Core.Framework
@@ -13,12 +8,17 @@ public class DotnetCoreService : IFrameworkService
138
private const string AKA_MS = @"https://aka.ms/dotnet";
149
private const string CHANNEL = "current";
1510

16-
public string GetLatestVersionUrl(FrameworkPlatform platform, FrameworkArchetecture archetecture)
11+
public string GetLatestVersionUrl(FrameworkPlatform platform, FrameworkArchitecture architecture)
1712
{
13+
if (platform == default)
14+
throw new ArgumentException("Platform cannot be default.");
15+
if (architecture == default)
16+
throw new ArgumentException("Architecture cannot be default.");
17+
1818
string product = GetProduct(platform);
1919
string extension = GetExtension(platform);
2020
string os = GetNormalizedOS(platform);
21-
string arch = GetNormalizedArchitecture(archetecture);
21+
string arch = GetNormalizedArchitecture(architecture);
2222

2323
switch (platform)
2424
{
@@ -73,13 +73,13 @@ private static string GetNormalizedOS(FrameworkPlatform platform)
7373
};
7474
}
7575

76-
private string GetNormalizedArchitecture(FrameworkArchetecture archetecture)
76+
private string GetNormalizedArchitecture(FrameworkArchitecture architecture)
7777
{
78-
return archetecture switch
78+
return architecture switch
7979
{
80-
FrameworkArchetecture.x64 => "x64",
81-
FrameworkArchetecture.x86 => "x86",
82-
FrameworkArchetecture.ARM64 => "arm64",
80+
FrameworkArchitecture.x64 => "x64",
81+
FrameworkArchitecture.x86 => "x86",
82+
FrameworkArchitecture.ARM64 => "arm64",
8383
_ => null
8484
};
8585
}

OpenTabletDriver.Web.Core/FrameworkArchetecture.cs renamed to OpenTabletDriver.Web.Core/FrameworkArchitecture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace OpenTabletDriver.Web.Core
22
{
3-
public enum FrameworkArchetecture
3+
public enum FrameworkArchitecture
44
{
55
Unknown = 0,
66
x86 = 1 << 0,
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using System.Threading.Tasks;
2-
31
namespace OpenTabletDriver.Web.Core.Services
42
{
53
public interface IFrameworkService
64
{
7-
string GetLatestVersionUrl(FrameworkPlatform platform, FrameworkArchetecture archetecture);
5+
string GetLatestVersionUrl(FrameworkPlatform platform, FrameworkArchitecture architecture);
86
}
97
}

OpenTabletDriver.Web/Controllers/FrameworkController.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Linq;
21
using Microsoft.AspNetCore.Mvc;
3-
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
4-
using Octokit;
52
using OpenTabletDriver.Web.Core;
63
using OpenTabletDriver.Web.Core.Services;
74

@@ -21,7 +18,7 @@ public IActionResult Index()
2118
string userAgentHeader = Request.Headers["User-Agent"];
2219
string userAgent = userAgentHeader.ToLower();
2320
FrameworkPlatform platform = FrameworkPlatform.Unknown;
24-
FrameworkArchetecture archetecture = FrameworkArchetecture.Unknown;
21+
FrameworkArchitecture architecture = FrameworkArchitecture.x64;
2522

2623
if (userAgent.Contains("windows"))
2724
platform = FrameworkPlatform.Windows;
@@ -31,13 +28,13 @@ public IActionResult Index()
3128
platform = FrameworkPlatform.MacOS;
3229

3330
if (platform == FrameworkPlatform.MacOS || userAgent.Contains("x86_64") || userAgent.Contains("x64"))
34-
archetecture = FrameworkArchetecture.x64;
31+
architecture = FrameworkArchitecture.x64;
3532
else if (userAgent.Contains("x86"))
36-
archetecture = FrameworkArchetecture.x86;
33+
architecture = FrameworkArchitecture.x86;
3734
else if (userAgent.Contains("arm64"))
38-
archetecture = FrameworkArchetecture.ARM64;
35+
architecture = FrameworkArchitecture.ARM64;
3936

40-
string url = frameworkService.GetLatestVersionUrl(platform, archetecture);
37+
string url = frameworkService.GetLatestVersionUrl(platform, architecture);
4138
return Redirect(url);
4239
}
4340
}

0 commit comments

Comments
 (0)