mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Make serializer cache use a tuple key
This commit is contained in:
parent
b3420e080e
commit
89556d5dfa
1 changed files with 3 additions and 3 deletions
|
@ -17,7 +17,7 @@ namespace LBPUnion.ProjectLighthouse.Serialization;
|
||||||
public static class LighthouseSerializer
|
public static class LighthouseSerializer
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly Dictionary<Type, CustomXmlSerializer> serializerCache = new();
|
private static readonly Dictionary<(Type, XmlRootAttribute?), CustomXmlSerializer> serializerCache = new();
|
||||||
|
|
||||||
private static readonly XmlSerializerNamespaces emptyNamespace = new(new[]
|
private static readonly XmlSerializerNamespaces emptyNamespace = new(new[]
|
||||||
{
|
{
|
||||||
|
@ -32,11 +32,11 @@ public static class LighthouseSerializer
|
||||||
|
|
||||||
public static CustomXmlSerializer GetSerializer(Type type, XmlRootAttribute? rootAttribute = null)
|
public static CustomXmlSerializer GetSerializer(Type type, XmlRootAttribute? rootAttribute = null)
|
||||||
{
|
{
|
||||||
if (serializerCache.TryGetValue(type, out CustomXmlSerializer? value)) return value;
|
if (serializerCache.TryGetValue((type, rootAttribute), out CustomXmlSerializer? value)) return value;
|
||||||
|
|
||||||
CustomXmlSerializer serializer = new(type, rootAttribute);
|
CustomXmlSerializer serializer = new(type, rootAttribute);
|
||||||
|
|
||||||
serializerCache.Add(type, serializer);
|
serializerCache.Add((type, rootAttribute), serializer);
|
||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue