mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
6930b51c64
* `--rebase-todo-editor` launches this app as a git `sequence.editor` * `--rebase-message-editor` launches this app as a git `core.editor` which runs on background by reading rebasing jobs * `--core-editor` launches this app as a git `core.editor` * `--askpass` launches this app as a SSH askpass program
69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
using Avalonia.Controls;
|
|
using Avalonia.Media;
|
|
|
|
namespace SourceGit
|
|
{
|
|
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),
|
|
]
|
|
)]
|
|
[JsonSerializable(typeof(Models.InteractiveRebaseJobCollection))]
|
|
[JsonSerializable(typeof(Models.JetBrainsState))]
|
|
[JsonSerializable(typeof(Models.ThemeOverrides))]
|
|
[JsonSerializable(typeof(Models.Version))]
|
|
[JsonSerializable(typeof(ViewModels.Preference))]
|
|
[JsonSerializable(typeof(ViewModels.RepositorySettings))]
|
|
internal partial class JsonCodeGen : JsonSerializerContext { }
|
|
}
|