Skip to content

Commit

Permalink
Implement deserialization methods in Converters
Browse files Browse the repository at this point in the history
Previously, all deserialization methods in the Converters threw a 'NotImplementedException'. The new updates replace these methods with actual implementations, ensuring that when serialized objects are read back, they are correctly converted back to their original form. This change improves the overall functionality and efficiency of the serialization process.
  • Loading branch information
Ygg01 committed Jan 21, 2024
1 parent f4965f9 commit ea5d022
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Linguini.Serialization/Converters/PatternSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static bool TryReadPattern(JsonElement jsonValue, JsonSerializerOptions o
case "Placeable":
if (PlaceableSerializer.TryProcessPlaceable(element, options, out var placeable))
{
patternElements.Add(new Placeable(placeable));
patternElements.Add(placeable);
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TermReferenceSerializer : JsonConverter<TermReference>
{
public override TermReference Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
return ProcessTermReference(JsonSerializer.Deserialize<JsonElement>(ref reader, options), options);
}

public override void Write(Utf8JsonWriter writer, TermReference value, JsonSerializerOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class VariableReferenceSerializer : JsonConverter<VariableReference>
public override VariableReference Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
throw new NotImplementedException();
return ProcessVariableReference(JsonSerializer.Deserialize<JsonElement>(ref reader, options), options);
}

public override void Write(Utf8JsonWriter writer, VariableReference variableReference,
Expand Down
2 changes: 1 addition & 1 deletion Linguini.Serialization/Converters/VariantSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class VariantSerializer : JsonConverter<Variant>
{
public override Variant Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
return ReadVariant(JsonSerializer.Deserialize<JsonElement>(ref reader, options), options);
}

public override void Write(Utf8JsonWriter writer, Variant variant, JsonSerializerOptions options)
Expand Down

0 comments on commit ea5d022

Please sign in to comment.