Skip to content

Commit

Permalink
ASF -> 5.5.3.4
Browse files Browse the repository at this point in the history
System.Text.Json -> NewtonJson
  • Loading branch information
chr233 committed Mar 5, 2024
1 parent 8a6fc8c commit a448feb
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 59 deletions.
14 changes: 3 additions & 11 deletions ASFEnhance/ASFEnhance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@
using ArchiSteamFarm.Plugins.Interfaces;
using ArchiSteamFarm.Steam;
using ASFEnhance.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Composition;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using static SteamKit2.GC.CSGO.Internal.CProductInfo_SetRichPresenceLocalization_Request;

namespace ASFEnhance;

[Export(typeof(IPlugin))]
internal sealed class ASFEnhance : IASF, IBotCommand2, IBotFriendRequest
{
[JsonInclude]
[Required]
public string Name => nameof(ASFEnhance);

[JsonInclude]
[Required]
public Version Version => MyVersion;

[JsonInclude]
[Required]
[JsonProperty]
public static PluginConfig Config => Utils.Config;

private Timer? StatisticTimer { get; set; }
Expand Down Expand Up @@ -1086,7 +1078,7 @@ public Task OnLoaded()
}
catch (Exception ex) //错误日志
{
var cfg = JsonSerializer.Serialize(Config, JsonSerializerOptions.Default);
var cfg = JsonConvert.SerializeObject(Config, Formatting.Indented);

var sb = new StringBuilder();
sb.AppendLine(Langs.ErrorLogTitle);
Expand Down
1 change: 1 addition & 0 deletions ASFEnhance/ASFEnhance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="..\ArchiSteamFarm\ArchiSteamFarm\bin\$(Configuration)\$(TargetFramework)\plugins\" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Users\chr11\Downloads\asf-5.5.3.4\plugins\" SkipUnchangedFiles="true" />
</Target>

</Project>
6 changes: 3 additions & 3 deletions ASFEnhance/Account/HtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Web.Responses;
using ASFEnhance.Data;
using Newtonsoft.Json;
using System.Globalization;
using System.Text;
using System.Text.Json;
using static ASFEnhance.Account.CurrencyHelper;

namespace ASFEnhance.Account;
Expand Down Expand Up @@ -33,7 +33,7 @@ internal static class HtmlParser
content = match.Groups[1].Value;
try
{
var cursorData = JsonSerializer.Deserialize<AccountHistoryResponse.CursorData>(content);
var cursorData = JsonConvert.DeserializeObject<AccountHistoryResponse.CursorData>(content);
return cursorData;
}
catch
Expand Down Expand Up @@ -422,7 +422,7 @@ decimal ParseMoneyString(string strMoney)
}
try
{
var optionsList = JsonSerializer.Deserialize<List<NotificationPayload>>(payload);
var optionsList = JsonConvert.DeserializeObject<List<NotificationPayload>>(payload);
if (optionsList == null)
{
return null;
Expand Down
4 changes: 2 additions & 2 deletions ASFEnhance/Account/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using ArchiSteamFarm.Steam.Data;
using ArchiSteamFarm.Web.Responses;
using ASFEnhance.Data;
using Newtonsoft.Json;
using System.Net;
using System.Text;
using System.Text.Json;
using static ASFEnhance.Account.CurrencyHelper;

namespace ASFEnhance.Account;
Expand Down Expand Up @@ -299,7 +299,7 @@ internal static async Task<bool> RemoveLicense(Bot bot, uint subId)
new(NotificationType.SteamTurnNotification,option.SteamTurnNotification),
};

var json = JsonSerializer.Serialize(optionList);
var json = JsonConvert.SerializeObject(optionList);

var data = new Dictionary<string, string>(11) {
{ "notificationpreferences", json },
Expand Down
4 changes: 2 additions & 2 deletions ASFEnhance/Curator/HtmlParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ASFEnhance.Data;
using System.Text.Json;
using Newtonsoft.Json;
using System.Text.RegularExpressions;

namespace ASFEnhance.Curator;
Expand All @@ -25,7 +25,7 @@ internal static class HtmlParser
try
{
string jsonStr = match.Groups[1].Value;
var data = JsonSerializer.Deserialize<HashSet<CuratorItem>>(jsonStr);
var data = JsonConvert.DeserializeObject<HashSet<CuratorItem>>(jsonStr);
return data;
}
catch (Exception ex)
Expand Down
39 changes: 18 additions & 21 deletions ASFEnhance/Data/EditProfilePayload.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.Json.Serialization;
using Newtonsoft.Json;

namespace ASFEnhance.Data;

Expand All @@ -7,63 +7,60 @@ namespace ASFEnhance.Data;
/// </summary>
public class EditProfilePayload
{
/// <summary>
/// 昵称
/// </summary>
[JsonPropertyName("strPersonaName")]
[JsonProperty("strPersonaName")]
public string? PersonaName { get; set; }

[JsonPropertyName("strCustomURL")]
[JsonProperty("strCustomURL")]
public string? CustomURL { get; set; }

[JsonPropertyName("strRealName")]
[JsonProperty("strRealName")]
public string? RealName { get; set; }

[JsonPropertyName("strSummary")]
[JsonProperty("strSummary")]
public string? Summary { get; set; }

[JsonPropertyName("strAvatarHash")]
[JsonProperty("strAvatarHash")]
public string? AvatarHash { get; set; }

[JsonPropertyName("rtPersonaNameBannedUntil")]
[JsonProperty("rtPersonaNameBannedUntil")]
public long PersonaNameBannedUntil { get; set; }

[JsonPropertyName("rtProfileSummaryBannedUntil")]
[JsonProperty("rtProfileSummaryBannedUntil")]
public long ProfileSummaryBannedUntil { get; set; }

[JsonPropertyName("rtAvatarBannedUntil")]
[JsonProperty("rtAvatarBannedUntil")]
public long AvatarBannedUntil { get; set; }

[JsonPropertyName("LocationData")]
[JsonProperty("LocationData")]
public LocationData? Location { get; set; }

[JsonPropertyName("ProfilePreferences")]
[JsonProperty("ProfilePreferences")]
public ProfilePreferencesData? ProfilePreferences { get; set; }

public class LocationData
{
[JsonPropertyName("locCountry")]
[JsonProperty("locCountry")]
public string? Country { get; set; }

[JsonPropertyName("locCountryCode")]
[JsonProperty("locCountryCode")]
public string? CountryCode { get; set; }

[JsonPropertyName("locState")]
[JsonProperty("locState")]
public string? State { get; set; }

[JsonPropertyName("locStateCode")]
[JsonProperty("locStateCode")]
public string? StateCode { get; set; }

[JsonPropertyName("locCity")]
[JsonProperty("locCity")]
public string? City { get; set; }

[JsonPropertyName("locCityCode")]
[JsonProperty("locCityCode")]
public string? CityCode { get; set; }
}

public class ProfilePreferencesData
{
[JsonPropertyName("hide_profile_awards")]
[JsonProperty("hide_profile_awards")]
public int HideProfileAwards { get; set; }
}

Expand Down
8 changes: 4 additions & 4 deletions ASFEnhance/Data/EditProfileResponse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using SteamKit2;
using System.Text.Json.Serialization;

namespace ASFEnhance.Data;

Expand All @@ -11,18 +11,18 @@ public class EditProfileResponse
/// <summary>
/// 是否成功
/// </summary>
[JsonPropertyName("success")]
[JsonProperty("success")]
public EResult Success { get; set; }

/// <summary>
/// 错误消息
/// </summary>
[JsonPropertyName("errmsg")]
[JsonProperty("errmsg")]
public string? ErrMsg { get; set; }

/// <summary>
/// 重定向地址
/// </summary>
[JsonPropertyName("redirect")]
[JsonProperty("redirect")]
public string? Redirect { get; set; }
}
18 changes: 9 additions & 9 deletions ASFEnhance/Event/SteamAwardVoteData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.Json.Serialization;
using Newtonsoft.Json;

namespace ASFEnhance.Event;

Expand All @@ -7,32 +7,32 @@ namespace ASFEnhance.Event;
/// </summary>
internal sealed record SteamAwardVoteData
{
[JsonPropertyName("definitions")]
[JsonProperty("definitions")]
public DefinitionData? Definitions { get; init; }
[JsonPropertyName("user_votes")]
[JsonProperty("user_votes")]
public List<UserVoteData>? UserVotes { get; init; }

internal sealed record DefinitionData
{
[JsonPropertyName("votes")]
[JsonProperty("votes")]
public List<VoteData>? Votes { get; set; }
}

internal sealed record VoteData
{
[JsonPropertyName("voteid")]
[JsonProperty("voteid")]
public byte VoteId { get; set; }
[JsonPropertyName("active")]
[JsonProperty("active")]
public byte Active { get; set; }
}

internal sealed record UserVoteData
{
[JsonPropertyName("voteid")]
[JsonProperty("voteid")]
public byte VoteId { get; set; }
[JsonPropertyName("appid")]
[JsonProperty("appid")]
public uint Appid { get; set; }
[JsonPropertyName("communityitemid")]
[JsonProperty("communityitemid")]
public string? Communityitemid { get; set; }
}
}
4 changes: 2 additions & 2 deletions ASFEnhance/Event/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Steam.Integration;
using ASFEnhance.Data;
using Newtonsoft.Json;
using System.Text;
using System.Text.Json;

namespace ASFEnhance.Event;

Expand Down Expand Up @@ -270,7 +270,7 @@ internal static async Task MakeWinterSteamAwardVote(Bot bot, int gameID, int cat
var configEle = response?.Content?.QuerySelector<IElement>("#application_config");
var config = configEle?.GetAttribute("data-steam_awards_config") ?? "";

var data = JsonSerializer.Deserialize<SteamAwardVoteData>(config);
var data = JsonConvert.DeserializeObject<SteamAwardVoteData>(config);

if (data == null)
{
Expand Down
1 change: 0 additions & 1 deletion ASFEnhance/IPC/Requests/AppIdListRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace ASFEnhance.IPC.Requests;

Expand Down
1 change: 0 additions & 1 deletion ASFEnhance/IPC/Requests/ClainIdListRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace ASFEnhance.IPC.Requests;

Expand Down
5 changes: 3 additions & 2 deletions ASFEnhance/Profile/WebRequest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using AngleSharp.Dom;
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Steam.Data;
using ArchiSteamFarm.Steam.Integration;
using ArchiSteamFarm.Web;
using ArchiSteamFarm.Web.Responses;
using ASFEnhance.Data;
using Newtonsoft.Json;
using SteamKit2;
using System.Net;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

namespace ASFEnhance.Profile;

Expand Down Expand Up @@ -279,7 +280,7 @@ internal static async Task<bool> CraftBadge(Bot bot, SemaphoreSlim semaphore, ui

try
{
var payload = JsonSerializer.Deserialize<EditProfilePayload>(json);
var payload = JsonConvert.DeserializeObject<EditProfilePayload>(json);
return payload;
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.0.14.1</Version>
<Version>2.0.14.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit a448feb

Please sign in to comment.