コード例 #1
0
ファイル: Page.cs プロジェクト: OneOfBestMan/JsonCMS
        public void LoadPageDataFromDb(string rootPath, string site, string pageName, Template template)
        {
            this.template = template.template;
            int sequence = 0;

            foreach (var region in template.regions)
            {
                region.sequence = sequence;
                this.regions.Add(region);
                sequence++;
            }

            RepoBase repo = RepoBase.RepoFactory(site, context, rootPath);

            if (repo == null)
            {
                throw new Exception("Repo not defined");
            }

            foreach (var region in regions)
            {
                switch (region.regionType)
                {
                case RegionType.Gallery:
                    var galleryRegion = repo.GetGalleryFromDb(region, pageName, rootPath);
                    galleryRegions.Add(galleryRegion);
                    break;

                case RegionType.Html:
                    var htmlRegion = repo.GetHtmlFromDb(region, pageName);
                    htmlRegions.Add(htmlRegion);
                    break;
                }
            }
        }