forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.JsonCodeGen.cs
More file actions
72 lines (64 loc) · 2.53 KB
/
App.JsonCodeGen.cs
File metadata and controls
72 lines (64 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 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);
}
}
public class DataGridLengthConverter : JsonConverter<DataGridLength>
{
public override DataGridLength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var size = reader.GetDouble();
return new DataGridLength(size, DataGridLengthUnitType.Pixel, 0, size);
}
public override void Write(Utf8JsonWriter writer, DataGridLength value, JsonSerializerOptions options)
{
writer.WriteNumberValue(value.DisplayValue);
}
}
[JsonSourceGenerationOptions(
WriteIndented = true,
IgnoreReadOnlyFields = true,
IgnoreReadOnlyProperties = true,
Converters = [
typeof(ColorConverter),
typeof(GridLengthConverter),
typeof(DataGridLengthConverter),
]
)]
[JsonSerializable(typeof(Models.ExternalToolPaths))]
[JsonSerializable(typeof(Models.InteractiveRebaseJobCollection))]
[JsonSerializable(typeof(Models.JetBrainsState))]
[JsonSerializable(typeof(Models.ThemeOverrides))]
[JsonSerializable(typeof(Models.Version))]
[JsonSerializable(typeof(Models.RepositorySettings))]
[JsonSerializable(typeof(Models.IssueTrackerMigrator.IssueTrackerRepositorySettingsVersion202526))]
[JsonSerializable(typeof(List<Models.VisualStudioInstance>))]
[JsonSerializable(typeof(ViewModels.Preferences))]
internal partial class JsonCodeGen : JsonSerializerContext { }
}