85 lines
2.5 KiB
C#
85 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
using System.Text.RegularExpressions;
|
|
using GoldbergGUI.Core.Utils;
|
|
|
|
// ReSharper disable UnusedMember.Global
|
|
// ReSharper disable ClassNeverInstantiated.Global
|
|
// ReSharper disable CollectionNeverUpdated.Global
|
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
|
// ReSharper disable StringLiteralTypo
|
|
// ReSharper disable InconsistentNaming
|
|
namespace GoldbergGUI.Core.Models
|
|
{
|
|
public class SteamApp
|
|
{
|
|
private string _name;
|
|
private string _comparableName;
|
|
[JsonPropertyName("appid")] public int AppId { get; set; }
|
|
|
|
[JsonPropertyName("name")]
|
|
public string Name
|
|
{
|
|
get => _name;
|
|
set
|
|
{
|
|
_name = value;
|
|
_comparableName = Regex.Replace(value, Misc.SpecialCharsRegex, "").ToLower();
|
|
}
|
|
}
|
|
|
|
public bool CompareName(string value) => _comparableName.Equals(value);
|
|
|
|
public AppType type { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{AppId}={Name}";
|
|
}
|
|
|
|
[JsonPropertyName("last_modified")] public long LastModified { get; set; }
|
|
|
|
[JsonPropertyName("price_change_number")]
|
|
public long PriceChangeNumber { get; set; }
|
|
}
|
|
|
|
public class AppList
|
|
{
|
|
[JsonPropertyName("apps")] public List<SteamApp> Apps { get; set; }
|
|
|
|
[JsonPropertyName("have_more_results")]
|
|
public bool HaveMoreResults { get; set; }
|
|
|
|
[JsonPropertyName("last_appid")] public long LastAppid { get; set; }
|
|
}
|
|
|
|
public class SteamApps
|
|
{
|
|
public virtual AppList AppList { get; set; }
|
|
}
|
|
|
|
public class SteamAppsV2 : SteamApps
|
|
{
|
|
[JsonPropertyName("applist")] public override AppList AppList { get; set; }
|
|
}
|
|
|
|
public class SteamAppsV1 : SteamApps
|
|
{
|
|
[JsonPropertyName("response")] public override AppList AppList { get; set; }
|
|
}
|
|
|
|
public class AppType
|
|
{
|
|
private AppType(string value) => Value = value;
|
|
|
|
public string Value { get; }
|
|
|
|
public static AppType Game => new AppType("game");
|
|
public static AppType DLC => new AppType("dlc");
|
|
public static AppType Music => new AppType("music");
|
|
public static AppType Demo => new AppType("demo");
|
|
public static AppType Ad => new AppType("advertising");
|
|
public static AppType Mod => new AppType("mod");
|
|
public static AppType Video => new AppType("video");
|
|
}
|
|
} |