Beispiel #1
0
 public PageController()
 {
     LayoutRegex = new Regex(@"^\s*Layout = "".*/_(?<layout>[^_\.]*)\.cshtml"";" + Environment.NewLine, RegexOptions.Compiled | RegexOptions.Multiline);
     PageSectionRegex = new Regex(@"@section[\s]*(?<section>[^\s]*)[\s\{]*(?<modules>[^\}]*)\}", RegexOptions.Compiled);
     PageModuleRegex = new Regex(@"Html.Partial\(""Modules/_(?<module>[^""]*)"".*\)", RegexOptions.Compiled);
     TitleRegex = new Regex(@"^\s*ViewBag\.Title\s*=\s*""(?<title>[^""]*)""\s*;" + Environment.NewLine, RegexOptions.Compiled | RegexOptions.Multiline);
     Controllers = new ControllerController();
     Layouts = new LayoutController();
     viewsFilepath = Path.GetFullPath(HttpRuntime.BinDirectory + @"..\Views\");
 }
Beispiel #2
0
        private void ResetPageLayout(PageInfo page)
        {
            var layoutController = new LayoutController();
            var layout =
                layoutController.Get(page.LayoutID)
                ?? layoutController.GetDefault();
            foreach (var section in layout.Sections)
            {
                var pageSections =
                    page.Sections
                    ?? new PageSectionInfo[0];
                var existingSection = pageSections
                    .FirstOrDefault(s => s.ID.Equals(section.ID, StringComparison.InvariantCultureIgnoreCase));
                if (existingSection == null)
                {
                    existingSection = SectionAdd(page.ID, section);
                }

                foreach (var module in section.Modules)
                {
                    var existingModule = existingSection.Modules
                        .FirstOrDefault(m => m.ID.Equals(module.ID, StringComparison.InvariantCultureIgnoreCase));
                    if (existingModule == null)
                    {
                        existingModule = ModuleAdd(new PageModuleInfo
                        {
                            ControllerID = page.ControllerID,
                            ID = module.ID,
                            Ordinal = module.Ordinal,
                            PageID = page.ID,
                            SectionID = module.SectionID,
                        });
                    }
                }
            }
        }