📄 basesyndicationwriter.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Collections;
using CommunityServer.Components;
namespace CommunityServer.Components
{
/// <summary>
/// The base class for all syndication (RSS, Atom, etc.) writers.
/// </summary>
public abstract class BaseSyndicationWriter : XmlTextWriter
{
const string styleElement = "<?xml-stylesheet type=\"text/xsl\" href=\"{0}\" media=\"screen\"?>";
protected string BaseUrl = null;
private string _styleSheet;
/// <summary>
/// Property StyleSheet (string)
/// </summary>
public string StyleSheet
{
get { return this._styleSheet; }
set { this._styleSheet = value; }
}
protected void WriteStyleSheet(string path)
{
this.WriteRaw(string.Format(styleElement,path));
}
/// <summary>
/// The StringWriter that we'll be using to store the output.
/// </summary>
private StringWriter sw = null;
private Section section;
/// <summary>
/// The configuration for the blog this feed is for.
/// </summary>
protected Section CurrentSection
{
get{return section;}
}
/// <summary>
/// The entries contained in this feed.
/// </summary>
protected ArrayList posts;
/// <summary>
/// Has the feed been built?
/// </summary>
private bool isBuilt = false;
/// <summary>
/// Constructs a new BaseSyndicationWriter for a set of entries and a StringWriter.
/// </summary>
/// <param name="entries">The entries to include in the feed.</param>
/// <param name="sw">The StringWriter to use for the feed.</param>
private BaseSyndicationWriter(ArrayList posts, Section s, string baseUrl, StringWriter sw) : base(sw)
{
this.posts = posts;
this.sw = sw;
section = s;
BaseUrl = baseUrl;
//sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
}
/// <summary>
/// Constructs a new BaseSyndicationWriter for a set of entries.
/// </summary>
/// <param name="entries">The entries to include in the feed.</param>
public BaseSyndicationWriter(ArrayList posts, Section s, string baseUrl) : this(posts, s, baseUrl, new StringWriter())
{
}
/// <summary>
/// Get the XML feed.
/// </summary>
public string GetXml()
{
if (!isBuilt)
{
Build();
isBuilt = true;
}
return this.sw.ToString();
}
public override string ToString()
{
return GetXml();
}
/// <summary>
/// Whether the feed writer should emit webbugs to count aggregator views.
/// </summary>
protected virtual bool UseAggBugs
{
get { return false; }
}
/// <summary>
/// Whether the feed writer should emit comment information for entries.
/// </summary>
protected virtual bool AllowComments
{
get { return true; }
}
/// <summary>
/// Builds the feed.
/// </summary>
protected abstract void Build();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -