in src/managed/DiffGen/ArchiveUtility/ArchiveTokenizationJsonConverter.cs [23:123]
public override ArchiveTokenization Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
reader.CheckStartObject();
string type = null;
string subtype = null;
ItemDefinition archiveItem = null;
ItemDefinition sourceItem = null;
SerializedPayloadList payload = null;
List<Recipe> recipes = null;
List<Recipe> forwardRecipes = null;
List<Recipe> reverseRecipes = null;
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
break;
}
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException();
}
string property = reader.GetString();
if (property == null)
{
throw new JsonException();
}
reader.Read();
switch (property)
{
case "Type":
type = reader.GetString();
break;
case "Subtype":
subtype = reader.GetString();
break;
case "ArchiveItem":
archiveItem = JsonSerializer.Deserialize<ItemDefinition>(ref reader, options);
break;
case "SourceItem":
sourceItem = JsonSerializer.Deserialize<ItemDefinition>(ref reader, options);
break;
case "Payload":
payload = JsonSerializer.Deserialize<SerializedPayloadList>(ref reader, options);
break;
case "Recipes":
recipes = JsonSerializer.Deserialize<List<Recipe>>(ref reader, options);
break;
case "ForwardRecipes":
forwardRecipes = JsonSerializer.Deserialize<List<Recipe>>(ref reader, options);
break;
case "ReverseRecipes":
reverseRecipes = JsonSerializer.Deserialize<List<Recipe>>(ref reader, options);
break;
default:
throw new JsonException();
}
}
if (type == null || subtype == null || archiveItem == null)
{
throw new JsonException();
}
ArchiveTokenization tokens = new(type, subtype);
tokens.ArchiveItem = archiveItem;
if (sourceItem != null)
{
tokens.SourceItem = sourceItem;
}
if (payload != null)
{
tokens.SetPayload(payload);
}
if (recipes != null)
{
tokens.SetRecipes(recipes);
}
if (forwardRecipes != null)
{
tokens.ForwardRecipes = forwardRecipes.Select(x => new KeyValuePair<ItemDefinition, Recipe>(x.Result, x)).ToDictionary();
}
if (reverseRecipes != null)
{
tokens.ReverseRecipes = reverseRecipes.Select(x => new KeyValuePair<ItemDefinition, Recipe>(x.Result, x)).ToDictionary();
}
return tokens;
}