本文整理汇总了C#中IPublishable类的典型用法代码示例。如果您正苦于以下问题:C# IPublishable类的具体用法?C# IPublishable怎么用?C# IPublishable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPublishable类属于命名空间,在下文中一共展示了IPublishable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ping
/// <summary>
/// Executes the pings from the new thread.
/// </summary>
/// <param name="item">
/// The publishable item.
/// </param>
/// <param name="itemUrl">
/// The item Url.
/// </param>
private static void Ping(IPublishable item, Uri itemUrl)
{
try
{
Thread.Sleep(2000);
// Ping the specified ping services.
PingService.Send(itemUrl);
// Send trackbacks and pingbacks.
if (!BlogSettings.Instance.EnableTrackBackSend && !BlogSettings.Instance.EnablePingBackSend)
{
return;
}
if (item.Content.ToUpperInvariant().Contains("\"HTTP"))
{
Manager.Send(item, itemUrl);
}
}
catch (Exception)
{
// We need to catch this exception so the application doesn't get killed.
}
}
示例2: Send
/// <summary>
/// Sends the trackback or pingback message.
/// <remarks>
/// It will try to send a trackback message first, and if the refered web page
/// doesn't support trackbacks, a pingback is sent.
/// </remarks>
/// </summary>
/// <param name="item">
/// The publishable item.
/// </param>
/// <param name="itemUrl">
/// The item Url.
/// </param>
public static void Send(IPublishable item, Uri itemUrl)
{
foreach (var url in GetUrlsFromContent(item.Content))
{
var trackbackSent = false;
if (BlogSettings.Instance.EnableTrackBackSend)
{
// ignoreRemoteDownloadSettings should be set to true
// for backwards compatibilty with Utils.DownloadWebPage.
var remoteFile = new RemoteFile(url, true);
var pageContent = remoteFile.GetFileAsString(); // ReadFromWeb(url);
var trackbackUrl = GetTrackBackUrlFromPage(pageContent);
if (trackbackUrl != null)
{
var message = new TrackbackMessage(item, trackbackUrl, itemUrl);
trackbackSent = Trackback.Send(message);
}
}
if (!trackbackSent && BlogSettings.Instance.EnablePingBackSend)
{
Pingback.Send(itemUrl, url);
}
}
}
示例3: Send
public static void Send(IPublishable item, Uri itemUrl)
{
foreach (var url in GetUrlsFromContent(item.Content))
{
var trackbackSent = false;
if (BlogSettings.Instance.EnableTrackBackSend)
{
var remoteFile = new RemoteFile(url, true);
var pageContent = remoteFile.GetFileAsString();
var trackbackUrl = GetTrackBackUrlFromPage(pageContent);
if (trackbackUrl != null)
{
var message = new TrackbackMessage(item, trackbackUrl, itemUrl);
trackbackSent = Trackback.Send(message);
}
}
if (!trackbackSent && BlogSettings.Instance.EnablePingBackSend)
{
Pingback.Send(itemUrl, url);
}
}
}
示例4: TrackbackMessage
/// <summary>
/// Initializes a new instance of the <see cref="TrackbackMessage"/> class.
/// </summary>
/// <param name="item">
/// The publishable item.
/// </param>
/// <param name="urlToNotifyTrackback">
/// The URL to notify trackback.
/// </param>
/// <param name="itemUrl">
/// The item Url.
/// </param>
public TrackbackMessage(IPublishable item, Uri urlToNotifyTrackback, Uri itemUrl)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
this.Title = item.Title;
this.PostUrl = itemUrl;
this.Excerpt = item.Title;
this.BlogName = GetBlogName();
this.UrlToNotifyTrackback = urlToNotifyTrackback;
}
示例5: InstanceSend
public void InstanceSend(IPublishable item, Uri itemUrl = null)
{
foreach (var url in GetUrlsFromContent(item.Content))
{
var trackbackSent = false;
if (IsTrackbackSendEnabled())
{
var trackbackUrl = GetTrackbackUrl(url);
if (trackbackUrl != null)
{
var message = GetTrackbackMessage(item, itemUrl, trackbackUrl);
trackbackSent = GetTrackbackSent(message);
}
}
if (!trackbackSent && IsPingbackEnabled())
{
SendPingback(itemUrl, url);
}
}
}
示例6: Send
/// <summary>
/// Sends the trackback or pingback message.
/// <remarks>
/// It will try to send a trackback message first, and if the refered web page
/// doesn't support trackbacks, a pingback is sent.
/// </remarks>
/// </summary>
public static void Send(IPublishable item, Uri itemUrl)
{
foreach (Uri url in GetUrlsFromContent(item.Content))
{
bool isTrackbackSent = false;
if (BlogSettings.Instance.EnableTrackBackSend)
{
string pageContent = Utils.DownloadWebPage(url);// ReadFromWeb(url);
Uri trackbackUrl = GetTrackBackUrlFromPage(pageContent);
if (trackbackUrl != null)
{
TrackbackMessage message = new TrackbackMessage(item, trackbackUrl, itemUrl);
isTrackbackSent = Trackback.Send(message);
}
}
if (!isTrackbackSent && BlogSettings.Instance.EnablePingBackSend)
{
Pingback.Send(itemUrl, url);
}
}
}
示例7: SendEmails
/// <summary>
/// Send emails to newsletter subscribers
/// </summary>
public static void SendEmails(IPublishable publishable)
{
var emails = LoadEmails();
if (emails != null && emails.Count > 0)
{
foreach (var email in emails)
{
if (!Utils.StringIsNullOrWhitespace(email) && Utils.IsEmailValid(email))
{
MailMessage message = CreateEmail(publishable);
message.To.Add(email);
try
{
Utils.SendMailMessage(message);
//Utils.Log("sent to " + email + " on - " + publishable.Title);
}
catch (Exception ex)
{
Utils.Log("Custom.Widgets.Newsletter.SendEmails", ex);
}
}
}
}
}
示例8: CreateEmail
/// <summary>
/// Creates the email.
/// </summary>
/// <param name="publishable">
/// The publishable to mail.
/// </param>
/// <returns>
/// The email.
/// </returns>
private static MailMessage CreateEmail(IPublishable publishable)
{
var mail = new MailMessage
{
Subject = publishable.Title,
Body = FormatBodyMail(publishable),
From = new MailAddress(BlogSettings.Instance.Email, BlogSettings.Instance.Name)
};
return mail;
}
示例9: ConvertToIPublishable
/// <summary>
/// A converter delegate used for converting Results to Posts.
/// </summary>
/// <param name="item">
/// The publishable item.
/// </param>
/// <returns>
/// Converts to publishable interface.
/// </returns>
private static IPublishable ConvertToIPublishable(IPublishable item)
{
return item;
}
示例10: GetDescription
string GetDescription(IPublishable post)
{
var description = Utils.StripHtml(post.Description);
if (description != null && description.Length > this.DescriptionMaxLength)
{
description = string.Format("{0}...", description.Substring(0, this.DescriptionMaxLength));
}
if (String.IsNullOrEmpty(description))
{
var content = Utils.StripHtml(post.Content);
description = content.Length > this.DescriptionMaxLength
? string.Format("{0}...", content.Substring(0, this.DescriptionMaxLength))
: content;
}
return description;
}
示例11: GetPermaLink
/// <summary>
/// Creates a <see cref="Uri"/> that represents the peramlink for the supplied <see cref="IPublishable"/>.
/// </summary>
/// <param name="publishable">The <see cref="IPublishable"/> used to generate the permalink for.</param>
/// <returns>A <see cref="Uri"/> that represents the peramlink for the supplied <see cref="IPublishable"/>.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="publishable"/> is a null reference (Nothing in Visual Basic).</exception>
private static Uri GetPermaLink(IPublishable publishable)
{
Training post = publishable as Training;
if (post != null)
{
return post.PermaLink;
}
return publishable.AbsoluteLink;
}
示例12: WriteAtomEntry
/// <summary>
/// Writes the Atom feed entry element information to the specified <see cref="XmlWriter"/> using the supplied <see cref="Page"/>.
/// </summary>
/// <param name="writer">
/// The <see cref="XmlWriter"/> to write feed entry element information to.
/// </param>
/// <param name="publishable">
/// The <see cref="IPublishable"/> used to generate feed entry content.
/// </param>
private static void WriteAtomEntry(XmlWriter writer, IPublishable publishable)
{
var post = publishable as Post;
// var comment = publishable as Comment;
// ------------------------------------------------------------
// Raise serving event
// ------------------------------------------------------------
var arg = new ServingEventArgs(publishable.Content, ServingLocation.Feed);
publishable.OnServing(arg);
if (arg.Cancel)
{
return;
}
// ------------------------------------------------------------
// Modify publishable content to make references absolute
// ------------------------------------------------------------
var content = Utils.ConvertPublishablePathsToAbsolute(arg.Body, publishable);
writer.WriteStartElement("entry");
// ------------------------------------------------------------
// Write required entry elements
// ------------------------------------------------------------
writer.WriteElementString("id", publishable.AbsoluteLink.ToString());
writer.WriteElementString("title", publishable.Title);
writer.WriteElementString("updated", ToW3CDateTime(publishable.DateCreated.ToUniversalTime()));
// ------------------------------------------------------------
// Write recommended entry elements
// ------------------------------------------------------------
writer.WriteStartElement("link");
writer.WriteAttributeString("rel", "self");
writer.WriteAttributeString("href", GetPermaLink(publishable).ToString());
writer.WriteEndElement();
writer.WriteStartElement("link");
writer.WriteAttributeString("href", publishable.AbsoluteLink.ToString());
writer.WriteEndElement();
writer.WriteStartElement("author");
writer.WriteElementString("name", publishable.Author);
writer.WriteEndElement();
writer.WriteStartElement("summary");
writer.WriteAttributeString("type", "html");
writer.WriteString(content);
writer.WriteEndElement();
// ------------------------------------------------------------
// Write optional entry elements
// ------------------------------------------------------------
writer.WriteElementString("published", ToW3CDateTime(publishable.DateCreated.ToUniversalTime()));
writer.WriteStartElement("link");
writer.WriteAttributeString("rel", "related");
writer.WriteAttributeString("href", String.Concat(publishable.AbsoluteLink.ToString(),
BlogSettings.Instance.ModerationType == BlogSettings.Moderation.Disqus ? "#disqus_thread" : "#comment"));
writer.WriteEndElement();
// ------------------------------------------------------------
// Write enclosure tag for podcasting support
// ------------------------------------------------------------
if (BlogSettings.Instance.EnableEnclosures)
{
var encloser = GetEnclosure(content, publishable);
if (!string.IsNullOrEmpty(encloser))
{
writer.WriteRaw(encloser);
}
}
// ------------------------------------------------------------
// Write entry category elements
// ------------------------------------------------------------
if (publishable.Categories != null)
{
foreach (var category in publishable.Categories)
{
writer.WriteStartElement("category");
writer.WriteAttributeString("term", category.Title);
writer.WriteEndElement();
}
}
// ------------------------------------------------------------
// Write Dublin Core syndication extension elements
// ------------------------------------------------------------
if (!String.IsNullOrEmpty(publishable.Author))
//.........这里部分代码省略.........
示例13: GetPermaLink
/// <summary>
/// Creates a <see cref="Uri"/> that represents the peramlink for the supplied <see cref="IPublishable"/>.
/// </summary>
/// <param name="publishable">
/// The <see cref="IPublishable"/> used to generate the permalink for.
/// </param>
/// <returns>
/// A <see cref="Uri"/> that represents the peramlink for the supplied <see cref="IPublishable"/>.
/// </returns>
/// <exception cref="ArgumentNullException">
/// The <paramref name="publishable"/> is a null reference (Nothing in Visual Basic).
/// </exception>
private static Uri GetPermaLink(IPublishable publishable)
{
var post = publishable as Post;
return post != null ? post.PermaLink : publishable.AbsoluteLink;
}
示例14: GetEnclosure
/// <summary>
/// Gets enclosure for supported media type
/// </summary>
/// <param name="content">The content.</param>
/// <param name="publishable">The publishable instance.</param>
/// <returns>The enclosure.</returns>
private static string GetEnclosure(string content, IPublishable publishable)
{
var enclosure = string.Empty;
fileSize = 0;
fileExists = false;
foreach (var media in SupportedMedia)
{
enclosure = GetMediaEnclosure(publishable, content, media.Key, media.Value);
if (enclosure.Length > 0)
{
break;
}
}
return enclosure;
}
示例15: GetTrackbackMessage
protected virtual TrackbackMessage GetTrackbackMessage(IPublishable item, Uri itemUrl, Uri trackbackUrl)
{
return new TrackbackMessage(item, trackbackUrl, itemUrl);
}