diff --git a/System.Application.SteamTools.Client.Desktop/Models/AchievementInfo.cs b/System.Application.SteamTools.Client.Desktop/Models/AchievementInfo.cs new file mode 100644 index 000000000..d14238cdb --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/AchievementInfo.cs @@ -0,0 +1,50 @@ +using System.Globalization; +using static System.Application.SteamApiUrls; + +namespace System.Application.Models +{ + public class AchievementInfo + { + public int AppId { get; set; } + + public string? Id { get; set; } + + public float Percent { get; set; } + + public string? Name { get; set; } + + public string? Description { get; set; } + + public string? IconNormal { get; set; } + + public string? IconLocked { get; set; } + + public bool IsHidden { get; set; } + + public bool IsAchieved { get; set; } + + public bool IsChecked { get; set; } + + public long UnlockTimeUnix { get; set; } + + public DateTime UnlockTime { get; set; } + + public string IconUrl => string.Format( + STEAMAPP_ICON_URL, + AppId, + IsAchieved ? IconNormal : IconLocked); + + public int Permission { get; set; } + + public bool IsProtection => (Permission & 3) != 0; + + public override string ToString() + { + return string.Format( + CultureInfo.CurrentCulture, + "{0}: {1}", + Name ?? Id ?? base.ToString(), + Permission); + } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/FloatStatInfo.cs b/System.Application.SteamTools.Client.Desktop/Models/FloatStatInfo.cs new file mode 100644 index 000000000..02a4a3e30 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/FloatStatInfo.cs @@ -0,0 +1,44 @@ +namespace System.Application.Models +{ + public class FloatStatInfo : StatInfo + { + public float OriginalValue { get; set; } + + public float FloatValue { get; set; } + + public float MinValue { get; set; } + + public float MaxValue { get; set; } + + public float MaxChange { get; set; } + + public bool IncrementOnly { get; set; } + + public float DefaultValue { get; set; } + + public override object Value + { + get { return FloatValue; } + set + { + var b = float.TryParse((string)value, out float f); + if (b) + { + if ((Permission & 2) != 0 && FloatValue != f) + { + //this.FloatValue = this.FloatValue; + } + else + { + FloatValue = f; + } + } + } + } + + public override bool IsModified + { + get { return FloatValue.Equals(OriginalValue) == false; } + } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/IntStatInfo.cs b/System.Application.SteamTools.Client.Desktop/Models/IntStatInfo.cs new file mode 100644 index 000000000..cce802e19 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/IntStatInfo.cs @@ -0,0 +1,44 @@ +namespace System.Application.Models +{ + public class IntStatInfo : StatInfo + { + public int OriginalValue { get; set; } + + public int IntValue { get; set; } + + public int MinValue { get; set; } + + public int MaxValue { get; set; } + + public int MaxChange { get; set; } + + public bool IncrementOnly { get; set; } + + public int DefaultValue { get; set; } + + public override object Value + { + get { return IntValue; } + set + { + var b = int.TryParse((string)value, out int i); + if (b) + { + if ((Permission & 2) != 0 && IntValue != i) + { + //this.IntValue = this.IntValue; + } + else + { + IntValue = i; + } + } + } + } + + public override bool IsModified + { + get { return IntValue != OriginalValue; } + } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/StatInfo.cs b/System.Application.SteamTools.Client.Desktop/Models/StatInfo.cs new file mode 100644 index 000000000..b6744698a --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/StatInfo.cs @@ -0,0 +1,47 @@ +using System.ComponentModel; + +namespace System.Application.Models +{ + public abstract class StatInfo + { + public abstract bool IsModified { get; } + + public string? Id { get; set; } + + public string? DisplayName { get; set; } + + public abstract object Value { get; set; } + + public bool IsIncrementOnly { get; set; } + + public int Permission { get; set; } + + public string Extra + { + get + { + var flags = StatFlags.None; + flags |= IsIncrementOnly == false ? 0 : StatFlags.IncrementOnly; + flags |= (Permission & 2) != 0 == false ? 0 : StatFlags.Protected; + flags |= (Permission & ~2) != 0 == false ? 0 : StatFlags.UnknownPermission; + return flags.ToString(); + } + } + } + + [Flags] + public enum StatFlags + { + [Description("默认")] + None = 0, + + [Description("仅增加")] + IncrementOnly = 1 << 0, + + [Description("受保护")] + Protected = 1 << 1, + + [Description("未知权限")] + UnknownPermission = 1 << 2, + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs new file mode 100644 index 000000000..eef31cbc8 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs @@ -0,0 +1,47 @@ +using System.Diagnostics; +using static System.Application.SteamApiUrls; + +namespace System.Application.Models +{ + public class SteamApp : IComparable + { + public int Index { get; set; } + + public uint AppId { get; set; } + + public bool IsInstalled { get; set; } + + public string? InstalledDir { get; set; } + + public string? Name { get; set; } + + public string? Logo { get; set; } + + public string? Icon { get; set; } + + public SteamAppType Type { get; set; } + + public string? LogoUrl => string.IsNullOrEmpty(Logo) ? null : + string.Format(STEAMAPP_LOGO_URL, AppId, Logo); + + public string HeaderLogoUrl => string.Format(STEAMAPP_CAPSULE_URL, AppId); + + public string? IconUrl => string.IsNullOrEmpty(Icon) ? null : + string.Format(STEAMAPP_LOGO_URL, AppId, Icon); + + public Process? Process { get; set; } + + public TradeCard? Card { get; set; } + + public SteamAppInfo? Common { get; set; } + + public int CompareTo(SteamApp? other) => string.Compare(Name, other?.Name); + + public string GetIdAndName() + { + return $"{AppId} | {Name}"; + } + } + + +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamAppInfo.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamAppInfo.cs new file mode 100644 index 000000000..c30be13a6 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamAppInfo.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; + +namespace System.Application.Models +{ + public class SteamAppInfo + { + public string? ClientIcon { get; set; } + + public string? ClientTga { get; set; } + + public string? Name { get; set; } + + public Dictionary? Languages { get; set; } + + public string? Logo { get; set; } + + public string? Logo_Small { get; set; } + + public string? Icon { get; set; } + + public string? OsList { get; set; } + + public string? Type { get; set; } + + public string? Metacritic_Name { get; set; } + + public Dictionary? Small_Capsule { get; set; } + + public Dictionary? Header_Image { get; set; } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamAppList.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamAppList.cs new file mode 100644 index 000000000..1f6a97940 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamAppList.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace System.Application.Models +{ + public class SteamAppList + { + public List? Apps { get; set; } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamAppType.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamAppType.cs new file mode 100644 index 000000000..5c28a9977 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamAppType.cs @@ -0,0 +1,70 @@ +using System.ComponentModel; + +namespace System.Application.Models +{ + public enum SteamAppType : byte + { + [Description("未知")] + Unknown = 0, + + [Description("游戏")] + Game = 1, + + [Description("软件")] + Application = 2, + + [Description("工具")] + Tool = 3, + + [Description("Demo")] + Demo = 4, + + [Description("预告视频")] + Media = 5, + + [Description("DLC")] + DLC = 6, + + [Description("指南")] + Guide = 7, + + [Description("驱动")] + Driver = 8, + + [Description("隐藏软件")] + Config = 9, + + [Description("硬件")] + Hardware = 10, + + [Description("授权")] + Franchise = 11, + + [Description("视频")] + Video = 12, + + [Description("插件")] + Plugin = 13, + + [Description("原声音轨")] + Music = 14, + + [Description("影视集")] + Series = 15, + + [Description("快捷方式")] + Shortcut = 16, + + [Description("仓库")] + DepotOnly = 17, + } + +#if DEBUG + + [Obsolete("use SteamAppType", true)] + public enum SteamAppTypeEnum + { + } + +#endif +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamApps.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamApps.cs new file mode 100644 index 000000000..42745c724 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamApps.cs @@ -0,0 +1,7 @@ +namespace System.Application.Models +{ + public class SteamApps + { + public SteamAppList? AppList { get; set; } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamUser.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamUser.cs new file mode 100644 index 000000000..f817b5d3b --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamUser.cs @@ -0,0 +1,147 @@ +using System.Xml.Serialization; +using static System.Application.SteamApiUrls; + +namespace System.Application.Models +{ + [XmlRoot("profile")] + public class SteamUser + { + public SteamUser() + { + } + + public SteamUser(string vdfstring) + { + OriginVdfString = vdfstring; + } + + public string SteamId3 { get; set; } + + public long SteamId3_Int => (SteamId64 >> 0) & 0xFFFFFFFF; + + public string SteamId32 { get; set; } + + public long SteamId32_Int { get; set; } + + [XmlElement("steamID64")] + public long SteamId64 { get; set; } + + /// + /// 个人资料链接 + /// + public string ProfileUrl => string.Format(STEAM_PROFILES_URL, SteamId64); + + /// + /// 在线状态 + /// + [XmlElement("onlineState")] + public string OnlineState { get; set; } + + public string IPCountry { get; set; } + + /// + /// 公开状态 + /// friendsonly + /// public + /// + [XmlElement("privacyState")] + public string PrivacyState { get; set; } + + /// + /// 头像小图标 + /// + [XmlElement("avatarIcon")] + public string AvatarIcon { get; set; } + + /// + /// 头像中等图片链接 + /// + [XmlElement("avatarMedium")] + public string AvatarMedium { get; set; } = "/Resources/Asstes/avater.jpg"; + + /// + /// 头像大图链接 + /// + [XmlElement("avatarFull")] + public string AvatarFull { get; set; } + + /// + /// 昵称 + /// + [XmlElement("steamID")] + public string SteamID { get; set; } + + /// + /// 昵称 + /// + public string SteamNickName => string.IsNullOrEmpty(SteamID) ? PersonaName : SteamID; + + /// + /// 从 Valve Data File 读取到的用户名 + /// + public string PersonaName { get; set; } + + /// + /// 用户名 + /// + public string AccountName { get; set; } + + /// + /// 是否记住密码 + /// + public bool RememberPassword { get; set; } + + /// + /// 密码 + /// + public string PassWord { get; set; } + + /// + /// 最后登录时间戳 + /// + public long Timestamp { get; set; } + + /// + /// 最后登录时间 + /// + public DateTime LastLoginTime { get; set; } + + /// + /// 最近登录 + /// + public bool MostRecent { get; set; } + + /// + /// 离线模式 + /// + public bool WantsOfflineMode { get; set; } + + /// + /// 忽略离线模式警告弹窗 + /// + public bool SkipOfflineModeWarning { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 来源VDF字符串 + /// + public string OriginVdfString { get; set; } + + /// + /// 导出VDF配置字符串 + /// + public string CurrentVdfString => + "\"" + SteamId64 + "\"\n{\n" + + "\t\t\"AccountName\"\t\t\"" + AccountName + "\"\n" + + "\t\t\"PersonaName\"\t\t\"" + PersonaName + "\"\n" + + "\t\t\"RememberPassword\"\t\t\"" + Convert.ToByte(RememberPassword) + "\"\n" + + "\t\t\"MostRecent\"\t\t\"" + Convert.ToByte(MostRecent) + "\"\n" + + "\t\t\"WantsOfflineMode\"\t\t\"" + Convert.ToByte(WantsOfflineMode) + "\"\n" + + "\t\t\"SkipOfflineModeWarning\"\t\t\"" + Convert.ToByte(SkipOfflineModeWarning) + "\"\n" + + "\t\t\"Timestamp\"\t\t\"" + Timestamp + "\"\n}"; + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Models/TradeCard.cs b/System.Application.SteamTools.Client.Desktop/Models/TradeCard.cs new file mode 100644 index 000000000..7963d9809 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Models/TradeCard.cs @@ -0,0 +1,11 @@ +namespace System.Application.Models +{ + public class TradeCard + { + public double MinutesPlayed { get; set; } + + public double Price { get; set; } + + public int CardSremaining { get; set; } + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Services/ISteamService.cs b/System.Application.SteamTools.Client.Desktop/Services/ISteamService.cs new file mode 100644 index 000000000..40eea32d7 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/Services/ISteamService.cs @@ -0,0 +1,46 @@ +namespace System.Application.Services +{ + public interface ISteamService + { + public static ISteamService Instance => DI.Get(); + + /// + /// Steam 文件夹目录 + /// + string SteamDirPath { get; } + + /// + /// Steam 主程序文件目录 + /// + string SteamProgramPath { get; } + + /// + /// 结束 Steam 进程 + /// + void KillSteamProcess(); + + /// + /// 启动 Steam + /// + /// + void StartSteam(string arguments = ""); + + /// + /// 获取最后一次自动登陆 Steam 用户名称 + /// + /// + string GetLastLoginUserName(); + } + +#if DEBUG + + [Obsolete("use ISteamService", true)] + public class SteamToolService + { + + [Obsolete("use SteamDirPath", true)] + public string? SteamPath { get; } + } + +#endif +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Services/OperationResult.cs b/System.Application.SteamTools.Client.Desktop/Services/OperationResult.cs index c9d0f268a..b62f533a8 100644 --- a/System.Application.SteamTools.Client.Desktop/Services/OperationResult.cs +++ b/System.Application.SteamTools.Client.Desktop/Services/OperationResult.cs @@ -128,7 +128,7 @@ namespace System.Application.Services } /// - public OperationResult(OperationResultType resultType, string message, string logMessage, T appendData) : base(resultType, message, logMessage, appendData) + public OperationResult(OperationResultType resultType, string message, string logMessage, object? appendData) : base(resultType, message, logMessage, appendData) { } diff --git a/System.Application.SteamTools.Client.Desktop/SteamApiUrls.cs b/System.Application.SteamTools.Client.Desktop/SteamApiUrls.cs new file mode 100644 index 000000000..61e74f00e --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/SteamApiUrls.cs @@ -0,0 +1,36 @@ +namespace System.Application +{ + public static class SteamApiUrls + { + public const string MY_PROFILE_URL = "https://steamcommunity.com/profiles/76561198289531723/"; + public const string MY_WISHLIST_URL = "https://store.steampowered.com/wishlist/profiles/76561198289531723/"; + public const string MY_MINIPROFILE_URL = "https://steamcommunity.com/miniprofile/329265995"; + + public const string STEAM_PROFILES_URL = "https://steamcommunity.com/profiles/{0}/badges/"; + + public const string STEAM_LOGIN_URL = "https://steamcommunity.com/login/home/?goto=my/profile"; + public const string STEAM_BADGES_URL = "https://steamcommunity.com/profiles/{0}/badges/"; + public const string STEAMAPP_LIST_URL = "https://api.steampowered.com/ISteamApps/GetAppList/v2"; + public const string STORE_APP_URL = "https://store.steampowered.com/app/{0}"; + public const string STEAMAPP_LOGO_URL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/{0}/{1}.jpg"; + public const string STEAMAPP_ICON_URL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/{0}/{1}"; + public const string STEAMAPP_CAPSULE_URL = "https://steamcdn-a.akamaihd.net/steam/apps/{0}/capsule_184x69.jpg"; + public const string STEAMAPP_HEADIMAGE_URL = "https://steamcdn-a.akamaihd.net/steam/apps/{0}/header.jpg"; + public const string STEAM_MEDIA_URL = "https://steamcdn-a.akamaihd.net/steam/apps/{0}/movie_max.webm"; + public const string STEAM_VIDEO_URL = "https://store.steampowered.com/video/watch/{0}/"; + public const string STEAM_REGISTERKEY_URL = "https://store.steampowered.com/account/registerkey?key={0}"; + public const string STEAM_FRIENDMESSAGESLOG_URL = "https://help.steampowered.com/zh-cn/accountdata/GetFriendMessagesLog"; + + public const string STEAM_INSTALL_URL = "steam://install/{0}"; + public const string STEAM_RUNGAME_URL = "steam://rungameid/{0}"; + public const string STEAM_OPENURL = "steam://openurl/{0}"; + public const string STEAM_RUN_KEYURL = "steam://openurl/https://store.steampowered.com/account/registerkey?key={0}"; + + public const string STEAMDB_USERINFO_URL = "https://api.steamdb.ml/v1/users/{0}"; + public const string STEAMDB_APPINFO_URL = "https://api.steamdb.ml/v1/apps/{0}"; + + public const string STEAM_USERINFO_XML_URL = "https://steamcommunity.com/profiles/{0}?xml=1"; + + public const string STEAMCN_USERINFO_XML_URL = "https://my.steamchina.com/profiles/76561198289531723?xml=1"; + } +} \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj b/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj index 9496ada8a..49fdef0e5 100644 --- a/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj +++ b/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj @@ -12,6 +12,7 @@ + diff --git a/System.Application.SteamTools.Client.Desktop/VdfHelper.cs b/System.Application.SteamTools.Client.Desktop/VdfHelper.cs new file mode 100644 index 000000000..0275b7c83 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/VdfHelper.cs @@ -0,0 +1,72 @@ +using Gameloop.Vdf; +using Gameloop.Vdf.Linq; +using System.IO; +using System.Text; + +namespace System.Application +{ + /// + /// Valve Data File 格式助手类 + /// + public static class VdfHelper + { + /// + /// 根据路径读取 Valve Data File 内容 + /// + /// + /// + public static VProperty Read(string filePath) + { + var text = File.ReadAllText(filePath, Encoding.UTF8); + return VdfConvert.Deserialize(text); + } + + public static void UpdateValueByReplace(string filePath, string oldVaule, string newValue) + { + var text = File.ReadAllText(filePath, Encoding.UTF8); + text = text.RemovePattern().Replace( + oldVaule.RemovePattern().Replace(" ", string.Empty), newValue); + File.WriteAllText(filePath, text, Encoding.UTF8); + } + + public static void DeleteValueByKey(string filePath, string key) + { + var text = File.ReadAllText(filePath, Encoding.UTF8); + // 如此实现的功能非常简单,但是应付嵌套的格式时会有问题 + var index = text.IndexOf($"\"{key}\""); + var lastIndex = text.IndexOf('}', index); + text = text.Remove(index, lastIndex - index + 1); + File.WriteAllText(filePath, text, Encoding.UTF8); + } + + public static void DeleteValueByReplace(string filePath, string oldVaule) + { + var text = File.ReadAllText(filePath, Encoding.UTF8); + text = text.Replace(oldVaule, string.Empty); + File.WriteAllText(filePath, text, Encoding.UTF8); + } + } + +#if DEBUG + + [Obsolete("use VdfHelper", true)] + public class VdfService + { + [Obsolete("use VdfHelper.UpdateValueByReplace", true)] + public void UpdateVdfValueByReplace(string path, string oldVaule, string newValue) + { + } + + [Obsolete("use VdfHelper.DeleteValueByKey", true)] + public void DeleteVdfValueByKey(string path, string key) + { + } + + [Obsolete("use VdfHelper.DeleteValueByReplace", true)] + public void DeleteVdfValueByReplace(string path, string oldVaule) + { + } + } + +#endif +} \ No newline at end of file diff --git a/System.Application.SteamTools.Services.CloudService.Models/Models/ApiResponseImpl.cs b/System.Application.SteamTools.Services.CloudService.Models/Models/ApiResponseImpl.cs index 13a524f9c..0214911b1 100644 --- a/System.Application.SteamTools.Services.CloudService.Models/Models/ApiResponseImpl.cs +++ b/System.Application.SteamTools.Services.CloudService.Models/Models/ApiResponseImpl.cs @@ -8,7 +8,7 @@ using SJsonProperty = System.Text.Json.Serialization.JsonPropertyNameAttribute; namespace System.Application.Models { - internal abstract class ApiResponseImplBase : Serializable, IApiResponse + internal abstract class ApiResponseImplBase : IApiResponse { ApiResponseCode mCode; bool mIsSuccess; diff --git a/System.Application.SteamTools.Services.CloudService/Services/CloudService/CloudServiceClientBase.cs b/System.Application.SteamTools.Services.CloudService/Services/CloudService/CloudServiceClientBase.cs index 0f1c23aee..81e6d2067 100644 --- a/System.Application.SteamTools.Services.CloudService/Services/CloudService/CloudServiceClientBase.cs +++ b/System.Application.SteamTools.Services.CloudService/Services/CloudService/CloudServiceClientBase.cs @@ -56,7 +56,7 @@ namespace System.Application.Services.CloudService } /// - internal string UserAgent => httpPlatformHelper.UserAgent; + internal string UserAgent => http_helper.UserAgent; IAuthHelper IApiConnectionPlatformHelper.Auth => authHelper; diff --git a/System.Application.SteamTools/GamePlatform.cs b/System.Application.SteamTools/GamePlatform.cs new file mode 100644 index 000000000..4dee23aa1 --- /dev/null +++ b/System.Application.SteamTools/GamePlatform.cs @@ -0,0 +1,46 @@ +using System.ComponentModel; + +namespace System.Application +{ + public enum GamePlatform : byte + { + [Description("Steam")] + Steam = 1, + + [Description("Origin")] + Origin = 2, + + [Description("EA Desktop")] + EADesktop = 10, + + [Description("Uplay")] + Uplay = 3, + + [Description("Microsoft Store")] + WinStore = 4, + + [Description("GOG")] + GOG = 5, + + [Description("EPIC")] + Epic = 6, + + [Description("PlayStation")] + PlayStation = 7, + + [Description("Xbox")] + Xbox = 8, + + [Description("NintendoSwitch")] + NintendoSwitch = 9, + } + +#if DEBUG + + [Obsolete("use GamePlatform", true)] + public enum GamePlatformEnum + { + } + +#endif +} \ No newline at end of file diff --git a/System.Common.CoreLib/Application/Models/PagedModel.cs b/System.Common.CoreLib/Application/Models/PagedModel.cs index 2364c5d31..8ef46b74f 100644 --- a/System.Common.CoreLib/Application/Models/PagedModel.cs +++ b/System.Common.CoreLib/Application/Models/PagedModel.cs @@ -12,7 +12,7 @@ namespace System.Application.Models [MPObj] [Serializable] [DebuggerDisplay("{DebuggerDisplay(),nq}")] - public sealed class PagedModel : Serializable, IPagedModel, IReadOnlyPagedModel + public sealed class PagedModel : IPagedModel, IReadOnlyPagedModel { string DebuggerDisplay() => $"Current: {Current}, Total: {Total}, Count: {mDataSource?.Count ?? 0}, PageSize: {PageSize}"; diff --git a/System.Common.CoreLib/ComponentModel/EnumDescriptionTypeConverter.cs b/System.Common.CoreLib/ComponentModel/EnumDescriptionTypeConverter.cs new file mode 100644 index 000000000..d2955027b --- /dev/null +++ b/System.Common.CoreLib/ComponentModel/EnumDescriptionTypeConverter.cs @@ -0,0 +1,39 @@ +using System.Globalization; + +namespace System.ComponentModel +{ + public class EnumDescriptionTypeConverter : EnumConverter + { + public EnumDescriptionTypeConverter(Type type) : base(type) + { + } + + public override object ConvertTo( + ITypeDescriptorContext context, + CultureInfo culture, + object value, + Type destinationType) + { + if (destinationType == typeof(string)) + { + if (null != value) + { + var fi = value.GetType().GetField(value.ToString()); + + if (null != fi) + { + var attributes = + (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); + + return ((attributes.Length > 0) && (!string.IsNullOrEmpty(attributes[0].Description))) + ? attributes[0].Description + : value.ToString(); + } + } + + return string.Empty; + } + return base.ConvertTo(context, culture, value, destinationType); + } + } +} \ No newline at end of file diff --git a/System.Common.CoreLib/System.Common.CoreLib.csproj b/System.Common.CoreLib/System.Common.CoreLib.csproj index 3a4562ad8..1f64c54fd 100644 --- a/System.Common.CoreLib/System.Common.CoreLib.csproj +++ b/System.Common.CoreLib/System.Common.CoreLib.csproj @@ -6,16 +6,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/source/SteamTool.Model/ToolModel/GithubReleaseModel.cs b/source/SteamTool.Model/ToolModel/GithubReleaseModel.cs index 7deb18ace..73b2195a9 100644 --- a/source/SteamTool.Model/ToolModel/GithubReleaseModel.cs +++ b/source/SteamTool.Model/ToolModel/GithubReleaseModel.cs @@ -4,6 +4,7 @@ using System.Text; namespace SteamTool.Model.ToolModel { + [Obsolete("use https://github.com/octokit/octokit.net")] public class GithubReleaseModel { public string id { get; set; } @@ -17,6 +18,7 @@ namespace SteamTool.Model.ToolModel public string body { get; set; } } + [Obsolete("use https://github.com/octokit/octokit.net")] public class Assets { public string id { get; set; }