Exemple #1
0
        /// <summary>Creates an instance from a RSS Enclosure.</summary>
        /// <param name="enclosure">RSS Enclosure.</param>
        /// <returns>Attachment Information.</returns>
        public static InfoAttach Create(RssEnclosure enclosure)
        {
            InfoAttach attach = new InfoAttach();

            attach._type      = enclosure.Type;
            attach._url       = enclosure.Url.AbsoluteUri;
            attach._length    = enclosure.Length;
            attach._id        = enclosure.Id;
            attach._name      = enclosure.Name;
            attach._title     = enclosure.Title;
            attach._timestamp = enclosure.Timestamp;
            attach._digestMd5 = enclosure.DigestMd5;

            return(attach);
        }
Exemple #2
0
        /// <summary>Creates an instance from a RSS Item.</summary>
        /// <param name="rssItem">RSS Item as source.</param>
        /// <param name="channel">The title of the channel.</param>
        /// <param name="targetEntry">RSS Target Entry.</param>
        public static InfoItem Create(RssItem rssItem, string channel, RssTargetEntry targetEntry)
        {
            InfoItem item = new InfoItem();

            item._generatorId = targetEntry.Id;
            item._author      = rssItem.Author;
            if (rssItem.Categories != null)
            {
                string[] categories = new string[rssItem.Categories.Count];
                int      idx        = 0;
                foreach (RssCategory cat in rssItem.Categories)
                {
                    categories[idx++] = cat.Name;
                }
                item._categories = categories;
            }
            item._comments    = rssItem.Comments;
            item._description = rssItem.Description;
            item._link        = rssItem.Link.ToString();
            item._guid        = rssItem.Guid.Name;
            item._pubDate     = rssItem.PubDate;
            item._title       = rssItem.Title;
            item._srcTitle    = targetEntry.Title;
            item._channel     = channel;

            if (rssItem.Enclosures != null)
            {
                ArrayList imageList  = new ArrayList();
                ArrayList attachList = new ArrayList();
                foreach (RssEnclosure enclosure in rssItem.Enclosures)
                {
                    if (enclosure.Type != null &&
                        enclosure.Type.IndexOf("image/") >= 0 &&
                        !targetEntry.IsZeptDist)
                    {
                        imageList.Add(enclosure.Url.ToString());
                    }
                    else
                    {
                        attachList.Add(InfoAttach.Create(enclosure));
                    }
                }
                if (imageList.Count > 0)
                {
                    item._images = (string[])imageList.ToArray(typeof(string));
                }
                if (attachList.Count > 0)
                {
                    item._attachments = (InfoAttach[])attachList.ToArray(typeof(InfoAttach));
                }
            }

#if ZEPTAIR
            if (rssItem.Description != null && rssItem.Description.Length > 0)
            {
                item._command = InfoCommand.Create(rssItem.Description);
            }
#endif

            return(item);
        }