예제 #1
0
        private static RssWriter Create(XmlTextWriter writer, RssVersion version)
        {
            RssWriter rssWriter = null;

            switch (version)
            {
            case RssVersion.RSS20:
                rssWriter = new Rss20Writer(writer);
                break;

            default:
                throw new NotSupportedException("The specified RSS version is not currently supported.");
            }
            return(rssWriter);
        }
예제 #2
0
 private static RssWriter Create(XmlTextWriter writer, RssVersion version)
 {
     RssWriter rssWriter = null;
     switch(version)
     {
         case RssVersion.RSS20:
             rssWriter = new Rss20Writer(writer);
             break;
         default:
             throw new NotSupportedException("The specified RSS version is not currently supported.");
     }
     return rssWriter;
 }
예제 #3
0
파일: lb.cs 프로젝트: mono/lb
    public void RenderRSS(string output, IList entries, int start, int end)
    {
        RssChannel channel = MakeChannel ();

        for (int i = start; i < end; i++){
            int idx = entries.Count - i - 1;
            if (idx < 0)
                continue;

            DayEntry d = (DayEntry) entries [idx];

            Hashtable substitutions = new Hashtable ();
            FillEntrySubstitutions (substitutions, d, config.BlogWebDirectory, false);
            StringWriter description = new StringWriter (new StringBuilder (d.Body.Length));
            Translate (d.Body, description, substitutions);

            StringWriter sw = new StringWriter (new StringBuilder (d.Body.Length));
            Render (sw, entries, idx, "", false, false);
            RssItem item = new RssItem ();
            item.Author = config.Author;
            item.Description = description.ToString ();
            item.Guid = new RssGuid ();
            item.Guid.Name = config.BlogWebDirectory + d.PermaLink;
            item.Link = new Uri (item.Guid.Name);
            item.Guid.PermaLink = DBBool.True;

            item.PubDate = d.Date.ToUniversalTime ();
            if (d.Caption == ""){
                Console.WriteLine ("No caption for: " + d.DateCaption);
                d.Caption = d.DateCaption;
            }
            item.Title = d.Caption;

            channel.Items.Add (item);
        }

        FileStream o = CreateFile (output);
        XmlTextWriter xtw = new XmlTextWriter (o, new UTF8Encoding (false));
        Rss20Writer w = new Rss20Writer (xtw);

        w.Write (channel);
        w.Close ();
    }