Esempio n. 1
0
        public static DirectoryStructure Parse(string file)
        {
            var d = new DirectoryStructure();

            d.Entry = file.Replace(Constants.RepositoryFolder, "").Substring(1);
            var lines = File.ReadLines(file);
            var title = (lines.SingleOrDefault(x => x.StartsWith("title:")) ?? "").Replace("title:", "").Trim();
            var order = (lines.SingleOrDefault(x => x.StartsWith("nav_sort:")) ?? "").Replace("nav_sort:", "").Trim();

            d.Description = title;
            d.Order       = string.IsNullOrEmpty(order) ? 0 : int.Parse(order);
            var folder = file.Replace(".md", "");

            if (System.IO.Directory.Exists(folder))
            {
                foreach (var file2 in Directory.EnumerateFiles(folder, "*.md"))
                {
                    d.Childrens.Add(DirectoryStructure.Parse(file2));
                }
            }

            d.Childrens = d.Childrens.OrderBy(x => x.Order).ToList();

            return(d);
        }
Esempio n. 2
0
        public void Parse(string folder)
        {
            foreach (var file in Directory.EnumerateFiles(folder, "*.md"))
            {
                Childrens.Add(DirectoryStructure.Parse(file));
            }

            Childrens = Childrens.OrderBy(x => x.Order).ToList();
        }