WinGui: Switch over to System.Text.Json for the Queue Services.
This commit is contained in:
parent
1e75e508a7
commit
d57a00a652
@ -14,18 +14,18 @@ namespace HandBrakeWPF.Helpers
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
|
||||
using HandBrake.Interop.Json;
|
||||
using HandBrake.Interop.Utilities;
|
||||
|
||||
using HandBrakeWPF.Services.Interfaces;
|
||||
using HandBrakeWPF.Services.Queue.Model;
|
||||
using HandBrakeWPF.Utilities;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using IQueueService = HandBrakeWPF.Services.Queue.Interfaces.IQueueService;
|
||||
using IQueueService = Services.Queue.Interfaces.IQueueService;
|
||||
|
||||
public class QueueRecoveryHelper
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace HandBrakeWPF.Helpers
|
||||
{
|
||||
using (StreamReader stream = new StreamReader(file))
|
||||
{
|
||||
List<QueueTask> list = list = JsonConvert.DeserializeObject<List<QueueTask>>(stream.ReadToEnd());
|
||||
List<QueueTask> list = list = JsonSerializer.Deserialize<List<QueueTask>>(stream.ReadToEnd(), JsonSettings.Options);
|
||||
if (list != null && list.Count == 0)
|
||||
{
|
||||
removeFiles.Add(file);
|
||||
|
@ -13,13 +13,13 @@ namespace HandBrakeWPF.Model.Audio
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
using HandBrake.Interop.Interop;
|
||||
using HandBrake.Interop.Interop.Model;
|
||||
using HandBrake.Interop.Interop.Model.Encoding;
|
||||
using Newtonsoft.Json;
|
||||
using Services.Encode.Model.Models;
|
||||
using Utilities;
|
||||
|
||||
|
@ -25,8 +25,6 @@ namespace HandBrakeWPF.Services.Encode.Factories
|
||||
using HandBrakeWPF.Services.Interfaces;
|
||||
using HandBrakeWPF.Utilities;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using AudioEncoder = Model.Models.AudioEncoder;
|
||||
using AudioEncoderRateType = Model.Models.AudioEncoderRateType;
|
||||
using AudioTrack = Model.Models.AudioTrack;
|
||||
@ -210,7 +208,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
private Video CreateVideo(EncodeTask job, HBConfiguration configuration)
|
||||
private Video CreateVideo(EncodeTask job, HBConfiguration configuration)
|
||||
{
|
||||
Video video = new Video();
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
@ -25,9 +26,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
|
||||
using HandBrakeWPF.Services.Scan.Model;
|
||||
using HandBrakeWPF.Utilities;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonObject(MemberSerialization.OptOut)]
|
||||
public class AudioTrack : PropertyChangedBase
|
||||
{
|
||||
private int bitrate;
|
||||
|
@ -13,9 +13,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonObject(MemberSerialization.OptOut)]
|
||||
public class ChapterMarker : PropertyChangedBase
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -9,17 +9,12 @@
|
||||
|
||||
namespace HandBrakeWPF.Services.Encode.Model.Models
|
||||
{
|
||||
using System;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
using HandBrake.Interop.Utilities;
|
||||
|
||||
using HandBrakeWPF.Services.Scan.Model;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonObject(MemberSerialization.OptOut)]
|
||||
public class SubtitleTrack : PropertyChangedBase
|
||||
{
|
||||
#region Constants and Fields
|
||||
|
@ -10,7 +10,6 @@
|
||||
namespace HandBrakeWPF.Services.Queue.Model
|
||||
{
|
||||
using System;
|
||||
using System.Xaml;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
@ -10,15 +10,11 @@
|
||||
namespace HandBrakeWPF.Services.Queue.Model
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
using HandBrakeWPF.Properties;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonObject(MemberSerialization.OptOut)]
|
||||
public class QueueStats : PropertyChangedBase
|
||||
{
|
||||
private DateTime startTime;
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace HandBrakeWPF.Services.Queue.Model
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
@ -19,8 +19,6 @@ namespace HandBrakeWPF.Services.Queue.Model
|
||||
using HandBrakeWPF.Services.Presets.Model;
|
||||
using HandBrakeWPF.Utilities;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
|
||||
|
||||
public class QueueTask : PropertyChangedBase
|
||||
@ -61,19 +59,16 @@ namespace HandBrakeWPF.Services.Queue.Model
|
||||
this.JobProgress = new QueueProgressStatus();
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public string TaskId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Id { get; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ScannedSourcePath { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid? TaskToken { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public QueueItemStatus Status
|
||||
{
|
||||
get
|
||||
@ -90,13 +85,10 @@ namespace HandBrakeWPF.Services.Queue.Model
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public EncodeTask Task { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public HBConfiguration Configuration { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public QueueStats Statistics { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
|
@ -12,15 +12,17 @@ namespace HandBrakeWPF.Services.Queue
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
|
||||
using HandBrake.Interop.Interop.Json.Queue;
|
||||
using HandBrake.Interop.Json;
|
||||
using HandBrake.Interop.Model;
|
||||
using HandBrake.Interop.Utilities;
|
||||
using HandBrake.Worker.Routing.Commands;
|
||||
|
||||
using HandBrakeWPF.Factories;
|
||||
using HandBrakeWPF.Helpers;
|
||||
@ -35,11 +37,7 @@ namespace HandBrakeWPF.Services.Queue
|
||||
using HandBrakeWPF.Services.Queue.JobEventArgs;
|
||||
using HandBrakeWPF.Services.Queue.Model;
|
||||
using HandBrakeWPF.Utilities;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Ookii.Dialogs.Wpf;
|
||||
|
||||
|
||||
using EncodeCompletedEventArgs = Encode.EventArgs.EncodeCompletedEventArgs;
|
||||
using Execute = Caliburn.Micro.Execute;
|
||||
using GeneralApplicationException = Exceptions.GeneralApplicationException;
|
||||
@ -172,7 +170,8 @@ namespace HandBrakeWPF.Services.Queue
|
||||
using (StreamWriter writer = new StreamWriter(tempPath))
|
||||
{
|
||||
List<QueueTask> tasks = this.queue.Where(item => item.Status != QueueItemStatus.Completed).ToList();
|
||||
string queueJson = JsonConvert.SerializeObject(tasks, Formatting.Indented);
|
||||
|
||||
string queueJson = JsonSerializer.Serialize(tasks, JsonSettings.Options);
|
||||
writer.Write(queueJson);
|
||||
}
|
||||
|
||||
@ -203,9 +202,7 @@ namespace HandBrakeWPF.Services.Queue
|
||||
{
|
||||
List<QueueTask> jobs = this.queue.Where(item => item.Status != QueueItemStatus.Completed).ToList();
|
||||
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||||
|
||||
string json = JsonConvert.SerializeObject(jobs, Formatting.Indented, settings);
|
||||
string json = JsonSerializer.Serialize(jobs, JsonSettings.Options);
|
||||
|
||||
using (var strm = new StreamWriter(exportPath, false))
|
||||
{
|
||||
@ -225,7 +222,7 @@ namespace HandBrakeWPF.Services.Queue
|
||||
return;
|
||||
}
|
||||
|
||||
List<QueueTask> reloadedQueue = JsonConvert.DeserializeObject<List<QueueTask>>(fileContent);
|
||||
List<QueueTask> reloadedQueue = JsonSerializer.Deserialize<List<QueueTask>>(fileContent);
|
||||
|
||||
if (reloadedQueue == null)
|
||||
{
|
||||
@ -449,7 +446,7 @@ namespace HandBrakeWPF.Services.Queue
|
||||
|
||||
try
|
||||
{
|
||||
list = JsonConvert.DeserializeObject<List<QueueTask>>(queueJson);
|
||||
list = JsonSerializer.Deserialize<List<QueueTask>>(queueJson);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@ -722,11 +719,6 @@ namespace HandBrakeWPF.Services.Queue
|
||||
|
||||
private string GetQueueJson(List<EncodeTask> tasks, HBConfiguration configuration)
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
};
|
||||
|
||||
List<Task> queueJobs = new List<Task>();
|
||||
foreach (var item in tasks)
|
||||
{
|
||||
@ -734,7 +726,7 @@ namespace HandBrakeWPF.Services.Queue
|
||||
queueJobs.Add(task);
|
||||
}
|
||||
|
||||
return JsonConvert.SerializeObject(queueJobs, Formatting.Indented, settings);
|
||||
return JsonSerializer.Serialize(queueJobs, JsonSettings.Options);
|
||||
}
|
||||
|
||||
private bool CheckDiskSpace(QueueTask job)
|
||||
|
Loading…
x
Reference in New Issue
Block a user