⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pingservices.cs

📁 个人博客系统
💻 CS
字号:
#region Using

using System;
using System.Xml;
using System.IO;
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
  {

    /// <summary>
    /// Loads the ping services.
    /// </summary>
    /// <returns></returns>
    public override StringCollection LoadPingServices()
    {
      string fileName = _Folder + "pingservices.xml";
      if (!File.Exists(fileName))
        return new StringCollection();

      StringCollection col = new StringCollection();
      XmlDocument doc = new XmlDocument();
      doc.Load(fileName);

      foreach (XmlNode node in doc.SelectNodes("services/service"))
      {
        if (!col.Contains(node.InnerText))
          col.Add(node.InnerText);
      }

      return col;
    }

    /// <summary>
    /// Saves the ping services.
    /// </summary>
    /// <param name="services">The services.</param>
    public override void SavePingServices(StringCollection services)
    {
      if (services == null)
        throw new ArgumentNullException("services");

      string fileName = _Folder + "pingservices.xml";

      using (XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8))
      {
        writer.Formatting = Formatting.Indented;
        writer.Indentation = 4;
        writer.WriteStartDocument(true);
        writer.WriteStartElement("services");

        foreach (string service in services)
        {
          writer.WriteElementString("service", service);
        }

        writer.WriteEndElement();
      }
    }

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -