예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuPartRenderer"/> class.
        /// </summary>
        /// <param name="menuPart">The menu part to be rendered.</param>
        public MenuPartRenderer(MenuPart menuPart)
        {
            this.menuPart = menuPart;
            var page = Context.CurrentPage;

            // Need the current page ID regardless of cached database or not to render selected page correctly.
            currentPageId = page == null ? 0 : page.ID;

#if NO_MENUPART_CACHE
            database = BuildNavigationTree(page);
#else
            if (page != null)
            {
                var cacheKey  = String.Concat(page.ID.ToString(CultureInfo.InvariantCulture), "+", menuPart.AncestralTrail);
                var cacheData = System.Web.Hosting.HostingEnvironment.Cache.Get(cacheKey);
                if (cacheData == null)
                {
                    cacheData = BuildNavigationTree(page);
                    System.Web.Hosting.HostingEnvironment.Cache.Add(cacheKey, cacheData, null, DateTime.Now.AddSeconds(15),
                                                                    System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
                }
                database = (List <ContentTreeNode>)cacheData;
            }
            else
            {
                database = new List <ContentTreeNode>();
            }
#endif
        }
예제 #2
0
파일: MenuPart.cs 프로젝트: fniwes/n2cms
        public MenuPartRenderer(MenuPart menuPart)
        {
            this.menuPart = menuPart;
            var cacheKey  = String.Concat(N2.Context.CurrentPage.ID.ToString(), "+", menuPart.AncestralTrail);
            var cacheData = System.Web.Hosting.HostingEnvironment.Cache.Get(cacheKey);

            if (cacheData == null)
            {
                cacheData = BuildNavTree();
                System.Web.Hosting.HostingEnvironment.Cache.Add(cacheKey, cacheData, null, DateTime.Now.AddSeconds(15),
                                                                System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
            }
            database = (List <ContentTreeNode>)cacheData;
        }
예제 #3
0
 private void WriteAfter(HtmlTextWriter xml, MenuPart menuPart)
 {
     xml.RenderEndTag();             // </div>
 }
예제 #4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MenuPartRenderer"/> class.
		/// </summary>
		/// <param name="menuPart">The menu part to be rendered.</param>
		public MenuPartRenderer(MenuPart menuPart)
		{
			this.menuPart = menuPart;
			var page = Context.CurrentPage;

			// Need the current page ID regardless of cached database or not to render selected page correctly.
			currentPageId = page == null ? 0 : page.ID;

#if NO_MENUPART_CACHE
			database = BuildNavigationTree(page);
#else
		    if (page != null)
		    {
		        var cacheKey = String.Concat(page.ID.ToString(CultureInfo.InvariantCulture), "+", menuPart.AncestralTrail);
		        var cacheData = System.Web.Hosting.HostingEnvironment.Cache.Get(cacheKey);
		        if (cacheData == null)
		        {
		            cacheData = BuildNavigationTree(page);
		            System.Web.Hosting.HostingEnvironment.Cache.Add(cacheKey, cacheData, null, DateTime.Now.AddSeconds(15),
		                System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
		        }
		        database = (List<ContentTreeNode>) cacheData;
		    }
		    else
		    {
		        database = new List<ContentTreeNode>();
		    }
#endif
		}
예제 #5
0
		private void WriteAfter(HtmlTextWriter xml, MenuPart menuPart)
		{
			xml.RenderEndTag(); // </div>
		}
예제 #6
0
		public MenuPartRenderer(MenuPart menuPart)
		{
			this.menuPart = menuPart;
			database = BuildNavTree();
		}