version 0.1.0

Added COPYING and README.md
Implemented Serilog
This commit is contained in:
Jeddunk 2021-01-14 19:38:31 +01:00
parent 32c48b01b9
commit a34ed8881d
11 changed files with 785 additions and 28 deletions

View file

@ -49,11 +49,11 @@ namespace GoldbergGUI.Core.Services
public class SteamService : ISteamService
{
// ReSharper disable StringLiteralTypo
private readonly Dictionary<string, SteamCache> _caches =
new Dictionary<string, SteamCache>
private readonly Dictionary<AppType, SteamCache> _caches =
new Dictionary<AppType, SteamCache>
{
{
AppType.Game.Value,
AppType.Game,
new SteamCache(
"steamapps_games.json",
"https://api.steampowered.com/IStoreService/GetAppList/v1/" +
@ -65,7 +65,7 @@ namespace GoldbergGUI.Core.Services
)
},
{
AppType.DLC.Value,
AppType.DLC,
new SteamCache(
"steamapps_dlc.json",
"https://api.steampowered.com/IStoreService/GetAppList/v1/" +
@ -102,7 +102,7 @@ namespace GoldbergGUI.Core.Services
foreach (var (k, c) in _caches)
{
_log = log;
_log.Info($"Updating cache ({k})...");
_log.Info($"Updating cache ({k.Value})...");
var updateNeeded =
DateTime.Now.Subtract(File.GetLastWriteTimeUtc(c.Filename)).TotalDays >= 1;
SteamApps steamApps;
@ -168,7 +168,7 @@ namespace GoldbergGUI.Core.Services
public IEnumerable<SteamApp> GetListOfAppsByName(string name)
{
var listOfAppsByName = _caches[AppType.Game.Value].Cache.Search(x => x.Name)
var listOfAppsByName = _caches[AppType.Game].Cache.Search(x => x.Name)
.SetCulture(StringComparison.OrdinalIgnoreCase)
.ContainingAll(name.Split(' '));
return listOfAppsByName;
@ -178,7 +178,7 @@ namespace GoldbergGUI.Core.Services
{
_log.Info($"Trying to get app {name}");
var comparableName = Regex.Replace(name, Misc.SpecialCharsRegex, "").ToLower();
var app = _caches[AppType.Game.Value].Cache.FirstOrDefault(x => x.CompareName(comparableName));
var app = _caches[AppType.Game].Cache.FirstOrDefault(x => x.CompareName(comparableName));
if (app != null) _log.Info($"Successfully got app {app}");
return app;
}
@ -186,7 +186,7 @@ namespace GoldbergGUI.Core.Services
public SteamApp GetAppById(int appid)
{
_log.Info($"Trying to get app with ID {appid}");
var app = _caches[AppType.Game.Value].Cache.FirstOrDefault(x => x.AppId.Equals(appid));
var app = _caches[AppType.Game].Cache.FirstOrDefault(x => x.AppId.Equals(appid));
if (app != null) _log.Info($"Successfully got app {app}");
return app;
}
@ -203,7 +203,7 @@ namespace GoldbergGUI.Core.Services
{
steamAppDetails.DLC.ForEach(x =>
{
var result = _caches[AppType.DLC.Value].Cache.FirstOrDefault(y => y.AppId.Equals(x))
var result = _caches[AppType.DLC].Cache.FirstOrDefault(y => y.AppId.Equals(x))
?? new SteamApp {AppId = x, Name = $"Unknown DLC {x}"};
dlcList.Add(result);
});