BlogEngine.Core/Ping/PingService.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

#region Using

using System;
using System.Net;
using System.Xml;
using System.IO;
using System.Text;
using System.Collections.Specialized;
using BlogEngine.Core;
using BlogEngine.Core.Providers;

#endregion

namespace BlogEngine.Core.Ping
{
  /// <summary>
  /// Pings various blog ping services.
  /// <remarks>
  /// Whenever a post is created or updated, it is important
  /// to notify the ping services so that they have the latest
  /// updated posts from the blog.
  /// </remarks>
  /// </summary>
  public static class PingService
  {
    /// <summary>
    /// Sends a ping to various ping services asynchronously.
    /// </summary>
    public static void Send(Uri url)
    {
      StringCollection services = BlogService.LoadPingServices();
      foreach (string service in services)
      {
        Execute(service, url);
      }
    }

    /// <summary>
    /// Creates a web request and invokes the response asynchronous.
    /// </summary>
    private static void Execute(string service, Uri url)
    {
      try
      {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(service);
        request.Method = "POST";
        request.ContentType = "text/xml";
        request.Timeout = 3000;
        request.Credentials = CredentialCache.DefaultNetworkCredentials;

        AddXmlToRequest(request, url);
        request.GetResponse();
      }
      catch (Exception)
      {
        // Log the error.
      }
    }

    /// <summary>
后面还有 24 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。