コード例 #1
0
        public IEnumerable <IPublishedContent> GetPosts(int nodeId, IPublishedContent currentPage)
        {
            IEnumerable <IPublishedContent> nodes;
            string str = "GetPosts_USNPosts_" + nodeId;
            IEnumerable <IPublishedContent> fromRequestCache = USNCacheHelper.GetFromRequestCache(str) as IEnumerable <IPublishedContent>;
            bool flag = fromRequestCache == null;

            if (flag)
            {
                string[] strArrays = new string[] { };
                IEnumerable <IPublishedContent>        descendentsOrSelf = this.GetDescendentsOrSelf(currentPage, "PageBlogPost", strArrays);
                IOrderedEnumerable <IPublishedContent> nodes1            = descendentsOrSelf.OrderByDescending <IPublishedContent, DateTime>((IPublishedContent x) =>
                {
                    DateTime value = DateTime.Parse(x.GetProperty("postDate").Value.ToString());
                    return(value);
                });
                USNCacheHelper.AddToRequestCache(str, nodes1);
                nodes = nodes1;
            }
            else
            {
                nodes = fromRequestCache;
            }
            return(nodes);
        }
コード例 #2
0
        public string GetValueFromAncestor(IPublishedContent node, string ancestorAlias, string propertyAlias)
        {
            string cacheKey = "USNBlog_GetValueFromAncestor_" + ancestorAlias;

            var root = USNCacheHelper.GetFromRequestCache(cacheKey) as IPublishedContent;

            if (root == null)
            {
                root = node.AncestorOrSelf(ancestorAlias);
                USNCacheHelper.AddToRequestCache(cacheKey, root);
            }

            return(root.GetProperty(propertyAlias).Value.ToString());
        }
コード例 #3
0
        public IPublishedContent GetLanding(IPublishedContent node)
        {
            string cacheKey = "GetLanding_USNBlogLanding_" + node.Id;

            var cached = USNCacheHelper.GetFromRequestCache(cacheKey) as IPublishedContent;

            if (cached != null)
            {
                return(cached);
            }

            var landing = node.AncestorOrSelf("USNBlogLandingPage");

            // cache the result
            USNCacheHelper.AddToRequestCache(cacheKey, landing);

            return(landing);
        }
コード例 #4
0
        public IPublishedContent GetSiteRoot(IPublishedContent node, string rootNodeTypeAlias)
        {
            string cacheKey = "GetSiteRoot_USNBlogSiteRoot";
            string noBlogSiteRootcacheKey = "GetSiteRoot_No_USNBlogSiteRoot";


            // try to get the "no site root result" from cache
            var cachedNoSiteRoot = USNCacheHelper.GetFromRequestCache(noBlogSiteRootcacheKey) as string;

            if (!string.IsNullOrEmpty(cachedNoSiteRoot) && cachedNoSiteRoot == noBlogSiteRootcacheKey)
            {
                // we've already cached the fact that there is no root.
                return(null);
            }

            // try to get the siteRoot from cache
            var cached = USNCacheHelper.GetFromRequestCache(cacheKey) as IPublishedContent;

            if (cached != null)
            {
                return(cached);
            }

            // try to get the site root
            var root = node.AncestorOrSelf(rootNodeTypeAlias);

            // site root was not found, so just return null
            if (root == null)
            {
                // cache the fact that there is no site root
                USNCacheHelper.AddToRequestCache(noBlogSiteRootcacheKey, noBlogSiteRootcacheKey);
                return(null);
            }

            // cache the result
            USNCacheHelper.AddToRequestCache(cacheKey, root);

            return(root);
        }