Esempio n. 1
0
        private String ReplaceFormattedString(String str, FeedReaderUrlConfiguration config, IFeedDocument doc, IFeedItem item)
        {
            Func<String, String> conv = s =>
            {
                if (String.IsNullOrEmpty(s))
                    return String.Empty;

                if (config.EnableRemoveLineBreak)
                {
                    // 改行コードを削除
                    s = _regexLineBreak.Replace(s, String.Empty);
                }
                else
                {
                    // 改行コードを LF(\n) に統一
                    s = _regexLineBreak.Replace(s, "\n");
                }

                // HTMLタグを削除
                if (config.EnableRemoveHtmlTag)
                {
                    s = _regexHtmlTag.Replace(s, String.Empty);
                }

                // HTML デコード
                s = Utility.UnescapeCharReference(s);

                return s;
            };

            // ${...} にすればよかった...
            StringBuilder sb = new StringBuilder(str);
            if (doc != null)
            {
                sb.Replace("#{feed_title}", conv(doc.Title));
                sb.Replace("#{feed_link}", conv(doc.Link.ToString()));
                sb.Replace("#{feed_description}", conv(doc.Description));
            }
            if (item != null)
            {
                sb.Replace("#{author}", conv(item.Author));
                sb.Replace("#{link}", conv(item.Link.ToString()));
                sb.Replace("#{title}", conv(item.Title));
                sb.Replace("#{description}", conv(item.Description));
                sb.Replace("#{publish_date}", conv(item.PublishDate.ToString()));
            }

            return sb.ToString();
        }
Esempio n. 2
0
        public void New()
        {
            FeedReaderEditContext context = Console.GetContext<FeedReaderEditContext>(CurrentServer, CurrentSession) as FeedReaderEditContext;

            var item = new FeedReaderUrlConfiguration();
            AddIn.RegisterEvents(item);

            context.Item = item;
            context.IsNew = true;
            Console.PushContext(context);
        }
Esempio n. 3
0
 internal void RegisterEvents(FeedReaderUrlConfiguration item)
 {
     item.ErrorHandled += new EventHandler<ErrorEventArgs>(OnErrorHandled);
     item.PublishDateUpdated += new EventHandler(OnPublishDateUpdated);
     item.FeedItemReceived += new EventHandler<FeedReceiveEventArgs>(OnFeedItemReceived);
 }