コード例 #1
0
        /// <summary>
        /// Used to safely obtain the POST title.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns></returns>
        public static string GetSafeTitle(this WPPostPageModel contentPostModel)
        {
            string title = "";

            if (contentPostModel?.title != null)
            {
                title = contentPostModel.title.rendered;
            }
            return(title);
        }
コード例 #2
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns Author1, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns tagCollection="empty"></returns>
        public static List <WPPostPageModel.Tag> GetTagCollection(this WPPostPageModel contentPostModel)
        {
            var tags = new List <WPPostPageModel.Tag>();

            try
            {
                if (ContainsTags(contentPostModel))
                {
                    tags = contentPostModel.tagColllection.ToList();
                }
            }
            catch (Exception ex)
            {
            }

            return(tags);
        }
コード例 #3
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns Author1, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns author="empty"></returns>
        public static WPPostPageModel.Author1 GetAuthor(this WPPostPageModel contentPostModel)
        {
            var wpAuthor = new WPPostPageModel.Author1();

            try
            {
                if (ContainsAuthor(contentPostModel))
                {
                    wpAuthor = contentPostModel._embedded.author.First();
                }
            }
            catch (Exception ex)
            {
            }

            return(wpAuthor);
        }
コード例 #4
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns List of WpTerm1s, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns List="WPTerms"></returns>
        public static List <WPPostPageModel.WpTerm1> GetTerms(this WPPostPageModel contentPostModel)
        {
            var wpTerms = new List <WPPostPageModel.WpTerm1>();

            try
            {
                if (ContainsTerms(contentPostModel))
                {
                    wpTerms = contentPostModel._embedded.wpterm.First().Select(a => a).ToList();
                }
            }
            catch (Exception ex)
            {
            }

            return(wpTerms);
        }
コード例 #5
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns FeaturedMedia.Media_Details.Sizes, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns Full="empty"></returns>
        public static WPPostPageModel.Full GetFullSizeImg(this WPPostPageModel contentPostModel)
        {
            var wpFullSizeImg = new WPPostPageModel.Full();

            try
            {
                if (ContainsFullSizeImage(contentPostModel))
                {
                    wpFullSizeImg = contentPostModel.GetMediaSizes().full;
                }
            }
            catch (Exception ex)
            {
            }

            return(wpFullSizeImg);
        }
コード例 #6
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns FeaturedMedia.Media_Details.Sizes, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns Sizes="empty"></returns>
        public static WPPostPageModel.Sizes GetMediaSizes(this WPPostPageModel contentPostModel)
        {
            var wpMediaSizes = new WPPostPageModel.Sizes();

            try
            {
                if (ContainsMediaSizes(contentPostModel))
                {
                    wpMediaSizes = contentPostModel.GetMediaDetails().sizes;
                }
            }
            catch (Exception ex)
            {
            }

            return(wpMediaSizes);
        }
コード例 #7
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns FeaturedMedia.Media_Details, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns Media_Details="empty"></returns>
        public static WPPostPageModel.Media_Details GetMediaDetails(this WPPostPageModel contentPostModel)
        {
            var wpMediaDetails = new WPPostPageModel.Media_Details();

            try
            {
                if (ContainsMediaDetails(contentPostModel))
                {
                    wpMediaDetails = contentPostModel.GetFeaturedMedia().media_details;
                }
            }
            catch (Exception ex)
            {
            }

            return(wpMediaDetails);
        }
コード例 #8
0
        /// <summary>
        /// NOT A SAFE CHECK.  Method returns  WPPostModel.WpFeaturedmedia, if is exists.  Otherwise, an empty object.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns WpFeaturedmedia="empty"></returns>
        public static WPPostPageModel.WpFeaturedmedia GetFeaturedMedia(this WPPostPageModel contentPostModel)
        {
            var wpFeaturedMedia = new WPPostPageModel.WpFeaturedmedia();

            try
            {
                if (ContainsFeaturedMedia(contentPostModel))
                {
                    wpFeaturedMedia = contentPostModel._embedded.wpfeaturedmedia.First();
                }
            }
            catch (Exception ex)
            {
            }

            return(wpFeaturedMedia);
        }
コード例 #9
0
        /// <summary>
        /// Checks to verify that Content exists
        /// </summary>
        /// <param name="contentPageModel"></param>
        /// <returns string="content"></returns>
        public static bool ContainsContent(this WPPostPageModel contentPageModel)
        {
            string content = null;

            try
            {
                if (contentPageModel?.content != null)
                {
                    content = contentPageModel.content.rendered;
                }
            }
            catch (Exception ex)
            {
                content = "";
            }

            return(!string.IsNullOrEmpty(content));
        }
コード例 #10
0
        /// <summary>
        /// Used to safely obtain the content of the POST contentType.
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns string="excerpt"></returns>
        public static string GetSafeExcerpt(this WPPostPageModel contentPostModel)
        {
            string excerpt = null;

            try
            {
                if (contentPostModel?.excerpt != null)
                {
                    excerpt = contentPostModel.excerpt.rendered;
                }
            }
            catch (Exception ex)
            {
                excerpt = "";
            }

            return(excerpt);
        }
コード例 #11
0
        /// <summary>
        /// Checks to verify that TagCollection exists
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns></returns>
        public static bool ContainsTagCollection(this WPPostPageModel contentPostModel)
        {
            bool tags = false;

            try
            {
                if (contentPostModel?.tagColllection != null && contentPostModel.tagColllection.Any())
                {
                    tags = true;
                }
            }
            catch (Exception ex)
            {
                tags = false;
            }

            return(tags);
        }
コード例 #12
0
        /// <summary>
        /// Checks to verify that Author exists
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns></returns>
        public static bool ContainsAuthor(this WPPostPageModel contentPostModel)
        {
            bool author = false;

            try
            {
                if (contentPostModel?._embedded?.author != null && contentPostModel._embedded.author.Any())
                {
                    author = true;
                }
            }
            catch (Exception ex)
            {
                author = false;
            }

            return(author);
        }
コード例 #13
0
        /// <summary>
        /// Used to safely obtain the content of the PAGE contentType.
        /// </summary>
        /// <param name="contentPageModel"></param>
        /// <returns string="content"></returns>
        public static string GetSafeContent(this WPPostPageModel contentPageModel)
        {
            string content = null;

            try
            {
                if (contentPageModel?.content != null)
                {
                    content = contentPageModel.content.rendered;
                }
            }
            catch (Exception ex)
            {
                content = "";
            }

            return(content);
        }
コード例 #14
0
        /// <summary>
        /// Checks to verify that WPTerms exists
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns></returns>
        public static bool ContainsTerms(this WPPostPageModel contentPostModel)
        {
            bool wpTerms = false;

            try
            {
                if (contentPostModel?._embedded?.wpterm != null && contentPostModel._embedded.wpterm.Any() &&
                    contentPostModel._embedded.wpterm.First().Any())
                {
                    wpTerms = true;
                }
            }
            catch (Exception ex)
            {
                wpTerms = false;
            }

            return(wpTerms);
        }
コード例 #15
0
        /// <summary>
        /// Checks to verify that FeaturedMedia exists
        /// </summary>
        /// <param name="contentPostModel"></param>
        /// <returns></returns>
        public static bool ContainsFeaturedMedia(this WPPostPageModel contentPostModel)
        {
            bool wpFeaturedMedia = false;

            try
            {
                if (contentPostModel?._embedded?.wpfeaturedmedia != null &&
                    contentPostModel._embedded.wpfeaturedmedia.Any())
                {
                    wpFeaturedMedia = true;
                }
            }
            catch (Exception ex)
            {
                wpFeaturedMedia = false;
            }

            return(wpFeaturedMedia);
        }