muffin v7.4.18
This commit is contained in:
parent
53aa9fdee8
commit
f82b9ce2a2
50 changed files with 142364 additions and 230361 deletions
|
|
@ -15,9 +15,7 @@ public sealed class StringListOrValueConverter : JsonConverter<List<string>>
|
|||
int num = 1;
|
||||
List<string> list = new List<string>(num);
|
||||
CollectionsMarshal.SetCount(list, num);
|
||||
Span<string> span = CollectionsMarshal.AsSpan(list);
|
||||
int index = 0;
|
||||
span[index] = reader.GetString();
|
||||
CollectionsMarshal.AsSpan(list)[0] = reader.GetString();
|
||||
return list;
|
||||
}
|
||||
if (reader.TokenType != JsonTokenType.StartArray)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Questionable.Model.Common.Converter;
|
||||
|
||||
public sealed class VectorListConverter : JsonConverter<List<Vector3>>
|
||||
{
|
||||
private static readonly VectorConverter ItemConverter = new VectorConverter();
|
||||
|
||||
public override List<Vector3> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType != JsonTokenType.StartArray)
|
||||
{
|
||||
throw new JsonException();
|
||||
}
|
||||
List<Vector3> list = new List<Vector3>();
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
list.Add(ItemConverter.Read(ref reader, typeof(Vector3), options));
|
||||
}
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, List<Vector3> value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
foreach (Vector3 item in value)
|
||||
{
|
||||
ItemConverter.Write(writer, item, options);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue