replace Newtonsoft.Json by System.Text.Json

This commit is contained in:
2021-08-04 15:03:15 +08:00
parent c727c6de87
commit a553b156f7
9 changed files with 375 additions and 45 deletions

View File

@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Gallery.Resources;
using Gallery.UI;
using Gallery.UI.Theme;
@ -897,7 +898,6 @@ namespace Gallery.Illust
ImageSource ProfileImage { get; }
}
[JsonObject(MemberSerialization.OptIn)]
public class IllustItem : BindableObject, IIllustItem
{
private static IllustItem empty;
@ -924,7 +924,6 @@ namespace Gallery.Illust
public static readonly BindableProperty BookmarkIdProperty = BindableProperty.Create(
nameof(BookmarkId), typeof(string), typeof(IllustItem));
[JsonProperty]
public string Title { get; set; }
public int Rank { get; set; }
public string RankTitle => Rank > 0 ? $"#{Rank} {Title}" : Title;
@ -950,49 +949,31 @@ namespace Gallery.Illust
}
public bool IsPlaying { get; set; }
[JsonProperty]
public string Id { get; set; }
[JsonProperty]
public string BookmarkId
{
get => (string)GetValue(BookmarkIdProperty);
set => SetValue(BookmarkIdProperty, value);
}
[JsonProperty]
public DateTime FavoriteDateUtc { get; set; }
[JsonProperty]
public string ImageUrl { get; set; }
[JsonProperty]
public bool IsRestrict { get; set; }
[JsonProperty]
public string[] Tags { get; set; }
[JsonProperty]
public string ProfileUrl { get; set; }
[JsonProperty]
public string UserId { get; set; }
[JsonProperty]
public string UserName { get; set; }
[JsonProperty]
public int Width { get; set; }
[JsonProperty]
public int Height { get; set; }
[JsonProperty]
public int PageCount { get; set; }
[JsonProperty]
public double ImageHeightValue
{
get => ImageHeight.IsAuto ? -1 : ImageHeight.Value;
set => ImageHeight = value > 0 ? value : GridLength.Auto;
}
[JsonProperty]
public int YesRank { get; set; }
[JsonProperty]
public int RatingCount { get; set; }
[JsonProperty]
public int ViewCount { get; set; }
[JsonProperty]
public long UploadTimestamp { get; set; }
[JsonProperty]
public IllustType IllustType { get; set; }
public string PageCountText => $"{StyleDefinition.IconLayer} {PageCount}";

View File

@ -177,9 +177,9 @@ namespace Gallery.Illust
var data = Stores.LoadIllustRankingData(lastQueryKey, queryDate, currentPage, out lastError, force);
if (data != null)
{
if (int.TryParse(data.next, out int next))
if (data.next != null)
{
nextPage = next;
nextPage = data.next.Value;
}
var date = data.date;
DateTime now;