Try Catch on Serialize

Better Relation Data
This commit is contained in:
2024-11-13 14:09:12 -07:00
parent 3fa7998ff6
commit 0505330ac5
17 changed files with 322 additions and 76 deletions

View File

@ -0,0 +1,25 @@
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL;
internal class Attribute
{
[JsonConstructor]
public Attribute(bool isLocked,
string name)
{
IsLocked = isLocked;
Name = name;
}
[JsonPropertyName("isLocked")] public bool IsLocked { get; }
[JsonPropertyName("name")] public string Name { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Attribute))]
internal partial class WIQLAttributeSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL;
internal class Relation
{
[JsonConstructor]
public Relation(string rel,
string url,
Attribute attributes)
{
Rel = rel;
Rel = rel;
URL = url;
Attributes = attributes;
}
[JsonPropertyName("attributes")] public Attribute Attributes { get; set; }
[JsonPropertyName("rel")] public string Rel { get; set; }
[JsonPropertyName("url")] public string URL { get; set; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Relation))]
internal partial class WIQLRelationSourceGenerationContext : JsonSerializerContext
{
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Relation[]))]
internal partial class WIQLRelationCollectionSourceGenerationContext : JsonSerializerContext
{
}