// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// Defines the QueueFactory type.
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Services.Encode.Factories
{
using System.Collections.Generic;
using HandBrake.ApplicationServices.Interop.Json.Queue;
using HandBrake.ApplicationServices.Model;
using HandBrakeWPF.Services.Encode.Model;
using Newtonsoft.Json;
///
/// The queue factory.
///
public class QueueFactory
{
///
/// For a givent set of tasks, return the Queue JSON that can be used for the CLI.
///
///
/// The tasks.
///
///
/// The configuration.
///
///
/// The .
///
public static string GetQueueJson(List tasks, HBConfiguration configuration)
{
JsonSerializerSettings settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
};
List queueJobs = new List();
foreach (var item in tasks)
{
Task task = new Task { Job = EncodeFactory.Create(item, configuration) };
queueJobs.Add(task);
}
return JsonConvert.SerializeObject(queueJobs, Formatting.Indented, settings);
}
}
}