Browse Source

Added sorting for properties

Kenric Nugteren 7 months ago
parent
commit
1edbf613d1
1 changed files with 7 additions and 7 deletions
  1. 7 7
      InABox.Core/DatabaseSchema/DatabaseSchema.cs

+ 7 - 7
InABox.Core/DatabaseSchema/DatabaseSchema.cs

@@ -11,8 +11,8 @@ namespace InABox.Core
     public static class DatabaseSchema
     {
         // {className: {propertyName: property}}
-        private static ConcurrentDictionary<Type, ImmutableDictionary<string, IProperty>> _properties
-            = new ConcurrentDictionary<Type, ImmutableDictionary<string, IProperty>>();
+        private static ConcurrentDictionary<Type, ImmutableSortedDictionary<string, IProperty>> _properties
+            = new ConcurrentDictionary<Type, ImmutableSortedDictionary<string, IProperty>>();
 
         private struct SubObject
         {
@@ -90,7 +90,7 @@ namespace InABox.Core
 
         public static void Clear()
         {
-            _properties = new ConcurrentDictionary<Type, ImmutableDictionary<string, IProperty>>();
+            _properties = new ConcurrentDictionary<Type, ImmutableSortedDictionary<string, IProperty>>();
         }
 
         private static void RegisterProperties(Type master, Type type, string prefix, StandardProperty? parent, Dictionary<string, IProperty> newProperties)
@@ -253,7 +253,7 @@ namespace InABox.Core
         {
             if (!_properties.TryGetValue(master, out var properties))
             {
-                properties = ImmutableDictionary<string, IProperty>.Empty;
+                properties = ImmutableSortedDictionary<string, IProperty>.Empty;
             }
             var newDict = properties.ToDictionary(x => x.Key, x => x.Value);
             foreach(var prop in toAdd)
@@ -261,7 +261,7 @@ namespace InABox.Core
                 newDict[prop.Name] = prop;
             }
 
-            _properties[master] = newDict.ToImmutableDictionary();
+            _properties[master] = newDict.ToImmutableSortedDictionary();
         }
         
         public static void RegisterProperty(IProperty entry)
@@ -271,7 +271,7 @@ namespace InABox.Core
 
             if (!_properties.TryGetValue(type, out var properties))
             {
-                properties = ImmutableDictionary<string, IProperty>.Empty;
+                properties = ImmutableSortedDictionary<string, IProperty>.Empty;
             }
             _properties[type] = properties.Add(entry.Name, entry);
         }
@@ -287,7 +287,7 @@ namespace InABox.Core
             }
         }
 
-        private static ImmutableDictionary<string, IProperty>? CheckPropertiesInternal(Type type)
+        private static ImmutableSortedDictionary<string, IProperty>? CheckPropertiesInternal(Type type)
         {
             try
             {