Prechádzať zdrojové kódy

Couple tweaks to CoreTable

Kenric Nugteren 4 mesiacov pred
rodič
commit
517d64b4ac

+ 3 - 3
InABox.Core/CoreTable/CoreRow.cs

@@ -294,10 +294,10 @@ namespace InABox.Core
 
 
         private int GetColumn(string columnname)
         private int GetColumn(string columnname)
         {
         {
-            if (_columnindexes.ContainsKey(columnname))
-                return _columnindexes[columnname];
+            if (_columnindexes.TryGetValue(columnname, out var index))
+                return index;
 
 
-            var index = Table.GetColumnIndex(columnname);
+            index = Table.GetColumnIndex(columnname);
             _columnindexes[columnname] = index;
             _columnindexes[columnname] = index;
             return index;
             return index;
         }
         }

+ 2 - 2
InABox.Core/CoreTable/CoreTable.cs

@@ -231,7 +231,7 @@ namespace InABox.Core
         {
         {
             var result = new Dictionary<TKey, TValue>();
             var result = new Dictionary<TKey, TValue>();
             var sorted = sort == null ? Rows : Rows.OrderBy(x => x.Get(sort)).ToList();
             var sorted = sort == null ? Rows : Rows.OrderBy(x => x.Get(sort)).ToList();
-            foreach (var row in Rows)
+            foreach (var row in sorted)
                 result[row.Get(key)] = row.Get(value);
                 result[row.Get(key)] = row.Get(value);
             return result;
             return result;
         }
         }
@@ -241,7 +241,7 @@ namespace InABox.Core
         {
         {
             var result = new Dictionary<TKey, string>();
             var result = new Dictionary<TKey, string>();
             var sorted = sort == null ? Rows : Rows.OrderBy(x => x.Get(sort)).ToList();
             var sorted = sort == null ? Rows : Rows.OrderBy(x => x.Get(sort)).ToList();
-            foreach (var row in Rows)
+            foreach (var row in sorted)
             {
             {
                 var display = new List<object>();
                 var display = new List<object>();
                 foreach (var value in values)
                 foreach (var value in values)