Browse Source

Use Dictionary instead of ImmutableDictionary

pull/333/head
Ionite 12 months ago
parent
commit
f18f61669f
No known key found for this signature in database
  1. 11
      StabilityMatrix.Avalonia/Helpers/ViewModelSerializer.cs

11
StabilityMatrix.Avalonia/Helpers/ViewModelSerializer.cs

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Text.Json.Serialization;
@ -9,16 +8,12 @@ namespace StabilityMatrix.Avalonia.Helpers;
public static class ViewModelSerializer
{
public static IImmutableDictionary<string, Type> GetDerivedTypes(Type baseType)
public static Dictionary<string, Type> GetDerivedTypes(Type baseType)
{
return GetJsonDerivedTypeAttributes(baseType)
.ToImmutableDictionary(x => x.typeDiscriminator, x => x.subType);
return GetJsonDerivedTypeAttributes(baseType).ToDictionary(x => x.typeDiscriminator, x => x.subType);
}
public static IEnumerable<(
Type subType,
string typeDiscriminator
)> GetJsonDerivedTypeAttributes(Type type)
public static IEnumerable<(Type subType, string typeDiscriminator)> GetJsonDerivedTypeAttributes(Type type)
{
return type.GetCustomAttributes<JsonDerivedTypeAttribute>()
.Select(x => (x.DerivedType, x.TypeDiscriminator as string ?? x.DerivedType.Name));

Loading…
Cancel
Save