From 5428cb948925d87aa581f8bfa1f7394ae2af905d Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Tue, 12 Jul 2022 21:04:33 +0200 Subject: [PATCH] Implemented method to calculate a section's path --- I18N Commander/Processor/SectionProcessor.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/I18N Commander/Processor/SectionProcessor.cs b/I18N Commander/Processor/SectionProcessor.cs index 7be9030..31be354 100644 --- a/I18N Commander/Processor/SectionProcessor.cs +++ b/I18N Commander/Processor/SectionProcessor.cs @@ -137,4 +137,17 @@ public static class SectionProcessor } public static Section GetSection(DataContext db, string sectionKey) => db.Sections.First(n => n.DataKey == sectionKey); + + public static string GetSectionPath(DataContext db, string sectionKey) + { + var section = db.Sections.First(n => n.DataKey == sectionKey); + var path = section.Name; + while (section.Parent != null) + { + section = section.Parent; + path = $"{section.Name}/{path}"; + } + + return $"Section's path: {path}"; + } } \ No newline at end of file