Exemple #1
0
        private ICollection <PageSection> GetSections(string file)
        {
            List <PageSection> sections = new List <PageSection>();
            var lines = File.ReadAllLines(file);

            foreach (var line in lines)
            {
                string text = line.Trim();
                if (text.StartsWith("@RenderSection("))
                {
                    var infos = text.Replace("@RenderSection(", "").Replace("\"", "").Replace(")", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (infos[0] == "head" || infos[0] == "end")
                    {
                        continue;
                    }
                    PageSection sec = new PageSection();
                    sec.Name = infos[0];
                    if (infos.Length > 1)
                    {
                        sec.Required = Convert.ToBoolean(infos[1]);
                    }
                    else
                    {
                        sec.Required = false;
                    }
                    sections.Add(sec);
                }
            }
            sections.Add(new PageSection()
            {
                Name     = "body",
                Required = false
            });
            return(sections);
        }
 private ICollection<PageSection> GetSections(string file)
 {
     List<PageSection> sections = new List<PageSection>();
     var lines = File.ReadAllLines(file);
     foreach (var line in lines)
     {
         string text = line.Trim();
         if (text.StartsWith("@RenderSection("))
         {
             var infos = text.Replace("@RenderSection(", "").Replace("\"", "").Replace(")", "").Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
             if (infos[0] == "head" || infos[0] == "end")
                 continue;
             PageSection sec = new PageSection();
             sec.Name = infos[0];
             if (infos.Length > 1)
             {
                 sec.Required = Convert.ToBoolean(infos[1]);
             }
             else
             {
                 sec.Required = false;
             }
             sections.Add(sec);
         }
     }
     sections.Add(new PageSection()
     {
         Name = "body",
         Required = false
     });
     return sections;
 }