using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
using Tizen.NUI.BaseComponents;
namespace SettingCore
public class Sections
{
private Dictionary<string, View> sections = new Dictionary<string, View>();
+ private List<Section> sectionList = new List<Section>();
public IEnumerable<View> Views => sections.Values;
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
}
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; }
+ }
}
}