Simplify lookup fallback code

This commit is contained in:
Dean Herbert 2020-06-22 16:32:27 +09:00
parent 1df89c6a59
commit 2d121b4e3d
1 changed files with 6 additions and 26 deletions

View File

@ -4,7 +4,6 @@
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using JetBrains.Annotations;
using Microsoft.Win32;
using osu.Framework.Allocation;
@ -187,32 +186,13 @@ public bool SetIPCLocation(string path)
[CanBeNull]
private string findStablePath()
{
string stableInstallPath = string.Empty;
var stableInstallPath = findFromEnvVar() ??
findFromRegistry() ??
findFromLocalAppData() ??
findFromDotFolder();
try
{
List<Func<string>> stableFindMethods = new List<Func<string>>
{
findFromEnvVar,
findFromRegistry,
findFromLocalAppData,
findFromDotFolder
};
foreach (var r in stableFindMethods)
{
stableInstallPath = r.Invoke();
if (stableInstallPath != null)
return stableInstallPath;
}
return null;
}
finally
{
Logger.Log($"Stable path for tourney usage: {stableInstallPath}");
}
Logger.Log($"Stable path for tourney usage: {stableInstallPath}");
return stableInstallPath;
}
private string findFromEnvVar()