2024-07-08 01:45:51 -07:00
|
|
|
|
using System;
|
|
|
|
|
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 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(
|
2024-07-09 21:11:51 -07:00
|
|
|
|
WriteIndented = true,
|
|
|
|
|
IgnoreReadOnlyFields = true,
|
|
|
|
|
IgnoreReadOnlyProperties = true,
|
2024-07-08 01:45:51 -07:00
|
|
|
|
Converters = [
|
|
|
|
|
typeof(ColorConverter),
|
|
|
|
|
typeof(GridLengthConverter),
|
|
|
|
|
]
|
|
|
|
|
)]
|
2024-08-14 20:32:02 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.ExternalToolPaths))]
|
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-09-11 03:22:05 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.OpenAIChatRequest))]
|
|
|
|
|
[JsonSerializable(typeof(Models.OpenAIChatResponse))]
|
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-07-22 23:52:25 -07:00
|
|
|
|
[JsonSerializable(typeof(Models.RepositorySettings))]
|
2024-03-26 07:11:06 -07:00
|
|
|
|
[JsonSerializable(typeof(ViewModels.Preference))]
|
|
|
|
|
internal partial class JsonCodeGen : JsonSerializerContext { }
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|