From 34b997933d996b01302abe9a09e4a3c29f809cda Mon Sep 17 00:00:00 2001 From: David Tremblay O'Neill Date: Tue, 27 Nov 2018 14:37:47 -0500 Subject: [PATCH] Tree nodes should be ordered by key. (#10) --- .../EnhancedDictionaryEditor.nuspec | 2 +- .../Repository/DictionnaryKeyTreeNodeRepository.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sigmund.EnhancedDictionaryEditor/EnhancedDictionaryEditor.nuspec b/Sigmund.EnhancedDictionaryEditor/EnhancedDictionaryEditor.nuspec index 866380a..7b5558b 100644 --- a/Sigmund.EnhancedDictionaryEditor/EnhancedDictionaryEditor.nuspec +++ b/Sigmund.EnhancedDictionaryEditor/EnhancedDictionaryEditor.nuspec @@ -2,7 +2,7 @@ EnhancedDictionaryEditor - 1.1.1 + 1.2.1 Sigmund,Davidton Sigmund,Davidton http://opensource.org/licenses/MIT diff --git a/Sigmund.EnhancedDictionaryEditor/Repository/DictionnaryKeyTreeNodeRepository.cs b/Sigmund.EnhancedDictionaryEditor/Repository/DictionnaryKeyTreeNodeRepository.cs index 052bc47..a4326f2 100644 --- a/Sigmund.EnhancedDictionaryEditor/Repository/DictionnaryKeyTreeNodeRepository.cs +++ b/Sigmund.EnhancedDictionaryEditor/Repository/DictionnaryKeyTreeNodeRepository.cs @@ -24,6 +24,7 @@ public DictionnaryKeyTreeNodeRepository(TreeController treeController) public TreeNodeCollection GetById(string id) { + var result = new TreeNodeCollection(); IEnumerable keys; if (id == RootTreeNodeId) @@ -34,14 +35,13 @@ public TreeNodeCollection GetById(string id) keys = LocalizationService.GetDictionaryItemChildren(Guid.Parse(id)); } - var nodes = new TreeNodeCollection(); + var nodes = keys + .OrderBy(x => x.ItemKey) + .Select(x => CreateTreeNode(x, id)); - foreach (var dictionnaryKey in keys) - { - nodes.Add(CreateTreeNode(dictionnaryKey, id)); - } + result.AddRange(nodes); - return nodes; + return result; } private TreeNode CreateTreeNode(IDictionaryItem item, string parentId)