Example #1
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Gets the first enclosure
        /// </summary>
        /// <param name="mimeType">Mime Type.  NOTE... paramters such as image, video, audio alone are also allowed.</param>
        /// <returns>RssCoreItemEnclosure</returns>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public RssCoreItemEnclosure GetFirstEnclosure(string medium = "", string mimeType = "")
        {
            RssCoreItemEnclosure rt = null;
            IEnumerable <RssCoreItemEnclosure> lst = GetEnclosures(medium, mimeType, ExitAfterOneFound: true);

            if (lst.Count() > 0)
            {
                rt = lst.First();
            }
            return(rt);
        }
Example #2
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Loads the properties of the RssCoreItem class with the contents of the parent element
        /// </summary>
        /// <param name="el">XElement</param>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public void LoadEl(XElement el)
        {
            RssRfc822DateTimeConverter dtConvert = new RssRfc822DateTimeConverter();

            switch (el.Name.LocalName)
            {
            case TAG_TITLE:
                title = xUtil.GetStr(el);
                break;

            case TAG_LINK:
                link = xUtil.GetStr(el);
                break;

            case TAG_DESCRIPTION:
                description = xUtil.GetStr(el);
                break;

            case TAG_AUTHOR:
                author = xUtil.GetStr(el);
                break;

            case TAG_CATEGORY:
                RssCoreItemCategory ctg = new RssCoreItemCategory();
                ctg.Load(el);
                categories.Add(ctg);
                break;

            case TAG_COMMENTS:
                comments = xUtil.GetStr(el);
                break;

            case TAG_ENCLOSURE:
                RssCoreItemEnclosure enc = new RssCoreItemEnclosure();
                enc.Load(el);
                enclosures.Add(enc);
                break;

            case TAG_GUID:
                guid = new RssCoreItemGuid();
                guid.Load(el);
                break;

            case TAG_PUBDATE:
                pubDate = dtConvert.ParseRfc822(xUtil.GetStr(el));
                break;

            case TAG_SOURCE:
                source = new RssCoreItemSource();
                source.Load(el);
                break;
            }   // end switch
        }
Example #3
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Adds an enclosure to the item.  Multiple enclosures are allowed by this library
        /// </summary>
        /// <param name="url">url of media item</param>
        /// <param name="length">length in bytes of media item</param>
        /// <param name="mimetype">mime type of media item</param>
        /// <returns></returns>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public bool AddEnclosure(string url, string mimetype, long length = 0)
        {
            bool rt = false;

            if (url.Length > 0)
            {
                RssCoreItemEnclosure enc = new RssCoreItemEnclosure();
                enc.url    = url;
                enc.length = length;
                enc.type   = mimetype;
                AddEnclosure(enc);

                rt = true;
            }
            return(rt);
        }
Example #4
0
 // -------------------------------------------------------------------------------
 // -------------------------------------------------------------------------------
 /// <summary>
 /// Adds an enclosure to the enclosures collection
 /// </summary>
 /// <param name="obj"></param>
 // -------------------------------------------------------------------------------
 // -------------------------------------------------------------------------------
 public void AddEnclosure(RssCoreItemEnclosure obj)
 {
     enclosures.Add(obj);
 }