diff --git a/Serializer.cs b/Serializer.cs
index 30c5994..c11ca3f 100644
--- a/Serializer.cs
+++ b/Serializer.cs
@@ -22,7 +22,7 @@ public class Serializer : ISerializer
/// An of s to use when deserializing s that refer other s through an ID.
public Serializer(IEnumerable? referenceSources = null)
{
- this.specialized = new(19)
+ this.Specialized = new(19)
{
{typeof(string), Serializer.simple},
{typeof(char), Serializer.simple},
@@ -46,8 +46,8 @@ public Serializer(IEnumerable? referenceSources = null)
{typeof(Vector3), Serializer.vector},
{typeof(Enum), new EnumSerializer()},
};
- this.referenceSources = referenceSources?.ToArray();
- this.referenceStorage = this.referenceSources is null ? null : new();
+ this.ReferenceSources = referenceSources?.ToHashSet();
+ this.referenceStorage = this.ReferenceSources is null ? null : new();
}
///
@@ -57,9 +57,9 @@ public Serializer(IEnumerable? referenceSources = null)
/// An of s to use when deserializing s that refer other s through an ID.
public Serializer(OrderedDictionary specializedSerializers, IEnumerable? referenceSources = null)
{
- this.specialized = specializedSerializers;
- this.referenceSources = referenceSources?.ToArray();
- this.referenceStorage = this.referenceSources is null ? null : new();
+ this.Specialized = specializedSerializers;
+ this.ReferenceSources = referenceSources?.ToHashSet();
+ this.referenceStorage = this.ReferenceSources is null ? null : new();
}
private const BindingFlags instanceBindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
@@ -68,32 +68,22 @@ public Serializer(OrderedDictionary specializedSerializers, I
private static readonly VectorSerializer vector = new();
- private readonly OrderedDictionary specialized;
-
- private readonly XmlNode[]? referenceSources;
-
private readonly Dictionary? referenceStorage;
///
/// Specialized s for specific s. These serializers will be used by the when possible.
///
- public IReadOnlyDictionary Specialized
+ public OrderedDictionary Specialized
{
- get
- {
- return this.specialized;
- }
+ get;
}
///
- /// An of s that contain s with IDs referenced by other s.
+ /// A of s that contain s with IDs referenced by other s.
///
- public IEnumerable ReferenceSources
+ public HashSet? ReferenceSources
{
- get
- {
- return this.referenceSources ?? Enumerable.Empty();
- }
+ get;
}
///
@@ -333,7 +323,7 @@ private bool TryGetSpecialSerializerForType(Type type, [NotNullWhen(true)] out I
private bool TryDeserializeReferencedNode(XmlNode node, out object? instance)
{
instance = null;
- if (this.referenceStorage is null)
+ if (this.referenceStorage is null || this.ReferenceSources is null)
{
return false;
}