From: Yurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics Date: Wed, 13 Dec 2023 15:21:08 +0000 (+0100) Subject: update sections X-Git-Tag: accepted/tizen/unified/20240205.162730~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8e26c8f539d4d0721eaf47ea8a18029f4b4469c;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsettings.git update sections --- diff --git a/SettingCore/Sections.cs b/SettingCore/Sections.cs index 4dc379e..5cf5ff6 100644 --- a/SettingCore/Sections.cs +++ b/SettingCore/Sections.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Tizen.NUI.BaseComponents; namespace SettingCore @@ -7,6 +9,7 @@ namespace SettingCore public class Sections { private Dictionary sections = new Dictionary(); + private List
sectionList = new List
(); public IEnumerable Views => sections.Values; @@ -29,6 +32,36 @@ namespace SettingCore return false; } + public void Add(string menuPath, Action action, Action init = null) + { + menuPath = menuPath.ToLowerInvariant(); + sectionList.Add(new Section + { + MenuPath = menuPath, + CreateItem = action, + Init = init + }); + } + + public Section GetSection(string menuPath) + { + return sectionList.Where(a => a.MenuPath == menuPath).FirstOrDefault(); + } + + public void InitSections() + { + var initList = sectionList.Where(a => a.Init != null).ToList(); + foreach (var section in initList) + { + section.InitComplete = Task.Run(() => section.Init); + } + } + + public void Clear() + { + sectionList.Clear(); + } + public bool TryGetValue(string menuPath, out View view) { try @@ -58,5 +91,13 @@ namespace SettingCore } sections.Clear(); } + + public class Section + { + public string MenuPath { get; set; } + public Action CreateItem { get; set; } + public Action Init { get; set; } + public Task InitComplete { get; set; } + } } }