您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->LiveBlog v1.0测试版源码>>LiveBlog.Core/Ping/Manager.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:LiveBlog v1.0测试版源码
当前文件:文件类型 LiveBlog/LiveBlog.Core/Ping/Manager.cs打开代码结构图
普通视图
		            
1Using 10 11namespace LiveBlog.Core.Ping 12{ 13 /// <summary> 14 /// Manages to send out trackbacks and then pingbacks if trackbacks aren't supported by the linked site. 15 /// </summary> 16 public static class Manager 17 { 18 /// <summary> 19 /// Sends the trackback or pingback message. 20 /// <remarks> 21 /// It will try to send a trackback message first, and if the refered web page 22 /// doesn't support trackbacks, a pingback is sent. 23 /// </remarks> 24 /// </summary> 25 public static void Send(IPublishable item) 26 { 27 foreach (Uri url in GetUrlsFromContent(item.Content)) 28 { 29 if (url.Host == Utils.AbsoluteWebRoot.Host) 30 continue; 31 32 string pageContent = ReadFromWeb(url); 33 Uri trackbackUrl = GetTrackBackUrlFromPage(pageContent); 34 bool isTrackbackSent = false; 35 36 if (trackbackUrl != null) 37 { 38 TrackbackMessage message = new TrackbackMessage(item, trackbackUrl); 39 isTrackbackSent = Trackback.Send(message); 40 } 41 42 if (!isTrackbackSent) 43 { 44 Pingback.Send(item.AbsoluteLink, url); 45 } 46 } 47 } 48 49 "RegEx Methods" 93 94 /// <summary> 95 /// Returns the HTML code of a given URL. 96 /// </summary> 97 /// <param name="sourceUrl">The URL you want to extract the html code.</param> 98 /// <returns></returns> 99 private static string ReadFromWeb(Uri sourceUrl) 100 { 101 string html; 102 using (WebClient client = new WebClient()) 103 { 104 client.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"); 105 html = client.DownloadString(sourceUrl); 106 } 107 return html; 108 } 109 } 110} 111
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:LiveBlog v1.0测试版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号