Swapped calls to intended TryGet variants

This commit is contained in:
Justin Swanson 2020-04-12 14:35:17 -05:00
parent e85f6b54dd
commit c4cce47399
7 changed files with 8 additions and 8 deletions

View File

@ -21,7 +21,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
{ {
Utils.Log($"Indexing game files"); Utils.Log($"Indexing game files");
var states = GameRegistry.Games.Values var states = GameRegistry.Games.Values
.Where(game => game.GameLocation() != null && game.MainExecutable != null) .Where(game => game.TryGetGameLocation() != null && game.MainExecutable != null)
.SelectMany(game => game.GameLocation().EnumerateFiles() .SelectMany(game => game.GameLocation().EnumerateFiles()
.Select(file => new GameFileSourceDownloader.State(game.InstalledVersion) .Select(file => new GameFileSourceDownloader.State(game.InstalledVersion)
{ {

View File

@ -85,7 +85,7 @@ namespace Wabbajack.Common
{ {
get get
{ {
AbsolutePath? gameLoc = GameLocation(); AbsolutePath? gameLoc = TryGetGameLocation();
if (gameLoc == null) if (gameLoc == null)
throw new GameNotInstalledException(this); throw new GameNotInstalledException(this);
if (MainExecutable == null) if (MainExecutable == null)
@ -95,7 +95,7 @@ namespace Wabbajack.Common
} }
} }
public bool IsInstalled => GameLocation() != null; public bool IsInstalled => TryGetGameLocation() != null;
public string? MainExecutable { get; internal set; } public string? MainExecutable { get; internal set; }

View File

@ -226,7 +226,7 @@ namespace Wabbajack.Common
return (Game)i; return (Game)i;
} }
GameMetaData? game = GameRegistry.GetByFuzzyName(str); GameMetaData? game = GameRegistry.TryGetByFuzzyName(str);
if (game == null) if (game == null)
{ {
throw new ArgumentException($"Could not convert {str} to a Game type."); throw new ArgumentException($"Could not convert {str} to a Game type.");

View File

@ -17,7 +17,7 @@ namespace Wabbajack.Lib.Downloaders
if (gameName == null || gameFile == null) if (gameName == null || gameFile == null)
return null; return null;
var game = GameRegistry.GetByFuzzyName(gameName); var game = GameRegistry.TryGetByFuzzyName(gameName);
if (game == null) return null; if (game == null) return null;
var path = game.TryGetGameLocation(); var path = game.TryGetGameLocation();

View File

@ -55,7 +55,7 @@ namespace Wabbajack.Lib
Queue.SetActiveThreadsObservable(ConstructDynamicNumThreads(await RecommendQueueSize())); Queue.SetActiveThreadsObservable(ConstructDynamicNumThreads(await RecommendQueueSize()));
if (GameFolder == null) if (GameFolder == null)
GameFolder = Game.GameLocation(); GameFolder = Game.TryGetGameLocation();
if (GameFolder == null) if (GameFolder == null)
{ {

View File

@ -26,7 +26,7 @@ namespace Wabbajack.Lib.NexusApi
{ {
var parts = link.Uri.AbsolutePath.Split('/', StringSplitOptions.RemoveEmptyEntries); var parts = link.Uri.AbsolutePath.Split('/', StringSplitOptions.RemoveEmptyEntries);
var foundGame = GameRegistry.GetByFuzzyName(parts[0]); var foundGame = GameRegistry.TryGetByFuzzyName(parts[0]);
if (foundGame == null) if (foundGame == null)
{ {
game = Game.Oblivion; game = Game.Oblivion;

View File

@ -124,7 +124,7 @@ namespace Wabbajack.Lib
var manualFilesDir = OutputFolder.Combine(Consts.ManualGameFilesDir); var manualFilesDir = OutputFolder.Combine(Consts.ManualGameFilesDir);
var gameFolder = GameInfo.GameLocation(); var gameFolder = GameInfo.TryGetGameLocation();
Info($"Copying files from {manualFilesDir} " + Info($"Copying files from {manualFilesDir} " +
$"to the game folder at {gameFolder}"); $"to the game folder at {gameFolder}");