BlogEngine.Core/Providers/XmlProvider/Posts.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
#region Using
using System;
using System.Xml;
using System.IO;
using System.Globalization;
using System.Collections.Generic;
using System.Collections.Specialized;
using BlogEngine.Core;
#endregion
namespace BlogEngine.Core.Providers
{
/// <summary>
/// A storage provider for BlogEngine that uses XML files.
/// <remarks>
/// To build another provider, you can just copy and modify
/// this one. Then add it to the web.config's BlogEngine section.
/// </remarks>
/// </summary>
public partial class XmlBlogProvider : BlogProvider
{
//private static string _Folder = System.Web.HttpContext.Current.Server.MapPath(BlogSettings.Instance.StorageLocation);
internal string _Folder
{
get
{
string p = StorageLocation().Replace("~/", "");
return System.IO.Path.Combine(System.Web.HttpRuntime.AppDomainAppPath, p);
}
}
/// <summary>
/// Retrieves a post based on the specified Id.
/// </summary>
public override Post SelectPost(Guid id)
{
string fileName = _Folder + "posts" + Path.DirectorySeparatorChar + id.ToString() + ".xml";
Post post = new Post();
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
post.Title = doc.SelectSingleNode("post/title").InnerText;
post.Description = doc.SelectSingleNode("post/description").InnerText;
post.Content = doc.SelectSingleNode("post/content").InnerText;
if (doc.SelectSingleNode("post/pubDate") != null)
post.DateCreated = DateTime.Parse(doc.SelectSingleNode("post/pubDate").InnerText, CultureInfo.InvariantCulture);
if (doc.SelectSingleNode("post/lastModified") != null)
post.DateModified = DateTime.Parse(doc.SelectSingleNode("post/lastModified").InnerText, CultureInfo.InvariantCulture);
if (doc.SelectSingleNode("post/author") != null)
post.Author = doc.SelectSingleNode("post/author").InnerText;
if (doc.SelectSingleNode("post/ispublished") != null)
post.IsPublished = bool.Parse(doc.SelectSingleNode("post/ispublished").InnerText);
后面还有 219 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
