|
@@ -31,7 +31,21 @@ namespace InABox.Core
|
|
|
|
|
|
public static class Serialization
|
|
|
{
|
|
|
- //private static JsonSerializerOptions? _serializerSettings;
|
|
|
+ /// <summary>
|
|
|
+ /// TypeInfoResolver modifier that removes properties that don't have setters.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="typeInfo"></param>
|
|
|
+ public static void WritablePropertiesOnly(JsonTypeInfo typeInfo)
|
|
|
+ {
|
|
|
+ if(typeInfo.Kind == JsonTypeInfoKind.Object)
|
|
|
+ {
|
|
|
+ var toRemove = typeInfo.Properties.Where(x => x.Set is null).ToList();
|
|
|
+ foreach(var prop in toRemove)
|
|
|
+ {
|
|
|
+ typeInfo.Properties.Remove(prop);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private static JsonConverter[]? _converters;
|
|
|
|