2024-07-08 01:45:51 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.Json;
|
2024-06-05 03:23:28 -07:00
|
|
|
|
using System.Text.Json.Serialization;
|
2024-03-26 07:11:06 -07:00
|
|
|
|
|
2024-07-08 01:45:51 -07:00
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Media;
|
|
|
|
|
|
2024-03-26 07:11:06 -07:00
|
|
|
|
namespace SourceGit
|
|
|
|
|
{
|
2024-07-08 01:45:51 -07:00
|
|
|
|
public class ColorConverter : JsonConverter<Color>
|
|
|
|
|
{
|
|
|
|
|
public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
|
|
|
{
|
|
|
|
|
return Color.Parse(reader.GetString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Write(Utf8JsonWriter writer, Color value, JsonSerializerOptions options)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteStringValue(value.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class FontFamilyConverter : JsonConverter<FontFamily>
|
|
|
|
|
{
|
|
|
|
|
public override FontFamily Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
|
|
|
{
|
|
|
|
|
var name = reader.GetString();
|
|
|
|
|
return new FontFamily(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Write(Utf8JsonWriter writer, FontFamily value, JsonSerializerOptions options)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteStringValue(value.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GridLengthConverter : JsonConverter<GridLength>
|
|
|
|
|
{
|
|
|
|
|
public override GridLength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
|
|
|
{
|
|
|
|
|
var size = reader.GetDouble();
|
|
|
|
|
return new GridLength(size, GridUnitType.Pixel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Write(Utf8JsonWriter writer, GridLength value, JsonSerializerOptions options)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteNumberValue(value.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonSourceGenerationOptions(
|
|
|
|
|
WriteIndented = true,
|
|
|
|
|
IgnoreReadOnlyFields = true,
|
|
|
|
|
IgnoreReadOnlyProperties = true,
|
|
|
|
|
Converters = [
|
|
|
|
|
typeof(ColorConverter),
|
|
|
|
|
typeof(FontFamilyConverter),
|
|
|
|
|
typeof(GridLengthConverter),
|
|
|
|
|
]
|
|
|
|
|
)]
|
2024-07-08 19:16:15 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.InteractiveRebaseJobCollection))]
|
2024-07-02 07:54:26 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.JetBrainsState))]
|
2024-07-08 01:21:57 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.ThemeOverrides))]
|
2024-07-02 07:54:26 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.Version))]
|
2024-03-26 07:11:06 -07:00
|
|
|
|
[JsonSerializable(typeof(ViewModels.Preference))]
|
2024-06-30 20:57:13 -07:00
|
|
|
|
[JsonSerializable(typeof(ViewModels.RepositorySettings))]
|
2024-03-26 07:11:06 -07:00
|
|
|
|
internal partial class JsonCodeGen : JsonSerializerContext { }
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|