fix(core): Adds priority support for GenericPersistence (#545)

This commit is contained in:
Kamron Batman 2021-03-09 23:49:19 -08:00 committed by GitHub
parent 432f8d2b70
commit 1ed23459bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -23,7 +23,8 @@ namespace Server
public static void Register(
string name,
Action<IGenericWriter> serializer,
Action<IGenericReader> deserializer
Action<IGenericReader> deserializer,
int priority = Persistence.DefaultPriority
)
{
BufferWriter saveBuffer = null;
@ -77,7 +78,7 @@ namespace Server
}
}
Persistence.Register(Serialize, WriterSnapshot, Deserialize);
Persistence.Register(Serialize, WriterSnapshot, Deserialize, priority);
}
}
}

View file

@ -23,13 +23,15 @@ namespace Server
{
public static class Persistence
{
public const int DefaultPriority = 100;
public static readonly SortedSet<RegistryEntry> _registry = new(new RegistryEntryComparer());
public static void Register(
Action serializer,
Action<string> snapshotWriter,
Action<string> deserializer,
int priority = 100
int priority = DefaultPriority
)
{
_registry.Add(