summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2021-01-15 22:21:17 +0000
committersr55 <[email protected]>2021-01-15 22:21:17 +0000
commitd57a00a652cce7ac8ea75937029e9c85ab9864d5 (patch)
treec4746d550829280375143698f77d1137ca01c2fd /win
parent1e75e508a7d626acf35281c19ac4dba7438b6887 (diff)
WinGui: Switch over to System.Text.Json for the Queue Services.
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs8
-rw-r--r--win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs4
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs4
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs3
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs5
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs1
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs4
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs10
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueService.cs28
10 files changed, 18 insertions, 51 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
index 6120c6b78..373448c0b 100644
--- a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
@@ -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);
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
index a6f8c9860..b6dd0fdd2 100644
--- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
+++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
@@ -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;
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs
index e6e3a79c0..da1fcf678 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs
@@ -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();
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
index 494c06096..44ce9c333 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
@@ -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;
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs
index 4e4e84e0e..1a2cbc542 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs
@@ -13,9 +13,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
using Caliburn.Micro;
- using Newtonsoft.Json;
-
- [JsonObject(MemberSerialization.OptOut)]
public class ChapterMarker : PropertyChangedBase
{
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs
index 7450f06e9..26eca6b94 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs
@@ -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
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs
index f759dfeb8..5ed36d5b9 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs
@@ -10,7 +10,6 @@
namespace HandBrakeWPF.Services.Queue.Model
{
using System;
- using System.Xaml;
using Caliburn.Micro;
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs
index 6295bab15..a9e95cab5 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs
@@ -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;
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
index 27e7eaa0c..1eeeba60e 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
@@ -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]
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
index 1a8802799..885fd0cdd 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
@@ -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)