mirror of
https://github.com/SabreTools/SabreTools.RedumpLib.git
synced 2026-09-24 07:54:28 +00:00
35 lines
1023 B
C#
35 lines
1023 B
C#
using System;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using SabreTools.RedumpLib.Data;
|
|
|
|
namespace SabreTools.RedumpLib.Converters
|
|
{
|
|
/// <summary>
|
|
/// Serialize Language enum values
|
|
/// </summary>
|
|
public class LanguageConverter : JsonConverter<Language?[]>
|
|
{
|
|
public override bool CanRead { get { return false; } }
|
|
|
|
public override Language?[] ReadJson(JsonReader reader, Type objectType, Language?[]? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void WriteJson(JsonWriter writer, Language?[]? value, JsonSerializer serializer)
|
|
{
|
|
if (value == null)
|
|
return;
|
|
|
|
JArray array = new JArray();
|
|
foreach (var val in value)
|
|
{
|
|
JToken t = JToken.FromObject(val.ShortName() ?? string.Empty);
|
|
array.Add(t);
|
|
}
|
|
|
|
array.WriteTo(writer);
|
|
}
|
|
}
|
|
} |