温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:LiveBlog v1.0测试版源码
当前文件:
LiveBlog/LiveBlog.Core/Providers/XmlProvider/PingServices.cs[1K,2009-6-12 11:47:02],打开代码结构图
LiveBlog/LiveBlog.Core/Providers/XmlProvider/PingServices.cs[1K,2009-6-12 11:47:02],打开代码结构图1Using 11
12
namespace LiveBlog.Core.Providers 13
{ 14
/// <summary> 15
/// A storage provider for BlogEngine that uses XML files. 16
/// <remarks> 17
/// To build another provider, you can just copy and modify 18
/// this one. Then add it to the web.config's BlogEngine section. 19
/// </remarks> 20
/// </summary> 21
public partial class XmlBlogProvider : BlogProvider 22
{ 23
24
/// <summary> 25
/// Loads the ping services. 26
/// </summary> 27
/// <returns></returns> 28
public override StringCollection LoadPingServices() 29
{ 30
string fileName = _Folder + "pingservices.xml"; 31
if (!File.Exists(fileName)) 32
return new StringCollection(); 33
34
StringCollection col = new StringCollection(); 35
XmlDocument doc = new XmlDocument(); 36
doc.Load(fileName); 37
38
foreach (XmlNode node in doc.SelectNodes("services/service")) 39
{ 40
if (!col.Contains(node.InnerText)) 41
col.Add(node.InnerText); 42
} 43
44
return col; 45
} 46
47
/// <summary> 48
/// Saves the ping services. 49
/// </summary> 50
/// <param name="services">The services.</param> 51
public override void SavePingServices(StringCollection services) 52
{ 53
if (services == null) 54
throw new ArgumentNullException("services"); 55
56
string fileName = _Folder + "pingservices.xml"; 57
58
using (XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8)) 59
{ 60
writer.Formatting = Formatting.Indented; 61
writer.Indentation = 4; 62
writer.WriteStartDocument(true); 63
writer.WriteStartElement("services"); 64
65
foreach (string service in services) 66
{ 67
writer.WriteElementString("service", service); 68
} 69
70
writer.WriteEndElement(); 71
} 72
} 73
74
} 75
} 76






