BlogEngine.Core.Providers.XmlBlogProvider.SelectPage C# (CSharp) Method

SelectPage() public method

Retrieves a Page from the provider based on the specified id.
public SelectPage ( System.Guid id ) : Page
id System.Guid The Page id.
return Page
        public override Page SelectPage(Guid id)
        {
            var fileName = string.Format("{0}pages{1}{2}.xml", this.Folder, Path.DirectorySeparatorChar, id);
            var doc = new XmlDocument();
            doc.Load(fileName);

            var page = new Page
                {
                    Title = doc.SelectSingleNode("page/title").InnerText,
                    Description = doc.SelectSingleNode("page/description").InnerText,
                    Content = doc.SelectSingleNode("page/content").InnerText,
                    Keywords = doc.SelectSingleNode("page/keywords").InnerText
                };

            if (doc.SelectSingleNode("page/slug") != null)
            {
                page.Slug = doc.SelectSingleNode("page/slug").InnerText;
            }

            if (doc.SelectSingleNode("page/parent") != null)
            {
                page.Parent = new Guid(doc.SelectSingleNode("page/parent").InnerText);
            }

            if (doc.SelectSingleNode("page/isfrontpage") != null)
            {
                page.IsFrontPage = bool.Parse(doc.SelectSingleNode("page/isfrontpage").InnerText);
            }

            if (doc.SelectSingleNode("page/showinlist") != null)
            {
                page.ShowInList = bool.Parse(doc.SelectSingleNode("page/showinlist").InnerText);
            }

            if (doc.SelectSingleNode("page/ispublished") != null)
            {
                page.IsPublished = bool.Parse(doc.SelectSingleNode("page/ispublished").InnerText);
            }

            if (doc.SelectSingleNode("page/isdeleted") != null)
            {
                page.IsDeleted = bool.Parse(doc.SelectSingleNode("page/isdeleted").InnerText);
            }

            page.DateCreated = DateTime.Parse(
                doc.SelectSingleNode("page/datecreated").InnerText, CultureInfo.InvariantCulture);
            page.DateModified = DateTime.Parse(
                doc.SelectSingleNode("page/datemodified").InnerText, CultureInfo.InvariantCulture);

            return page;
        }