Class SitecoreContext
Inheritance: AbstractSitecoreContext
コード例 #1
0
        public static SitecoreContext GetFromHttpContext(string contextName = null)
        {
            if (string.IsNullOrEmpty(contextName))
            {
                contextName = GetContextFromSite();
            }

            var cachedContexts = CachedContexts;

            if (cachedContexts == null)
            {
                return(new SitecoreContext(contextName));
            }
            else
            {
                SitecoreContext context = null;
                if (cachedContexts.ContainsKey(contextName))
                {
                    context = cachedContexts[contextName];
                }

                if (context == null)
                {
                    context = new SitecoreContext(contextName);
                    cachedContexts[contextName] = context;
                }
                return(context);
            }
        }
コード例 #2
0
 public List<CategoryItem> GetCategories()
 {
     //return new List<Category>();
     var context = new SitecoreContext();
     List<CategoryItem> categories = new List<CategoryItem>();
     categoryList = context.GetItem<CategoryList>(CATEGORY_ROOT_GUID);
     var categoryBucket = categoryList.Children.Select(a => new Category() 
     { 
         CategoryId = a.CategoryId,
         Title = a.Title, 
         Description = a.Description, 
         SmallImage = a.SmallImage 
     }).ToList<Category>().Where(x => x.Title != null);
     foreach (var v in categoryBucket)
     {
         categories.Add(new CategoryItem() { 
         CategoryId=v.CategoryId,
         Title=v.Title,
         Description=v.Description,
         SmallImage=v.SmallImage
         });
     }
     return categories;
 } 
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var context = new SitecoreContext();
     Model = context.GetCurrentItem<Homepage>();
 }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var context = new SitecoreContext();
     Model = context.GetHomeItem<MenuItem>();
 }
コード例 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var context = new SitecoreContext();
     lit1.Text = context.Database.Name;
 }
コード例 #6
0
        public static SitecoreContext GetFromHttpContext(string contextName = null)
        {
            if (string.IsNullOrEmpty(contextName))
            {
                contextName = GetContextFromSite();
            }

            var cachedContexts = CachedContexts;
            if (cachedContexts == null)
            {
                return new SitecoreContext(contextName);
            }
            else
            {
                SitecoreContext context = null;
                if (cachedContexts.ContainsKey(contextName))
                {
                    context = cachedContexts[contextName];
                }

                if (context == null)
                {
                    context = new SitecoreContext(contextName);
                    cachedContexts[contextName] = context;
                }
                return context;
            }

        }
コード例 #7
0
 private void Page_Load(object sender, EventArgs e)
 {
     var context = new SitecoreContext();
     Model = context.GetCurrentItem<BoxFeatures>();
 }
コード例 #8
0
 private void Page_Load(object sender, EventArgs e)
 {
     var context = new SitecoreContext();
     Model = context.GetHomeItem<NavBar>();
 }
コード例 #9
0
 public ActionResult ContactUs()
 {
     var context = new SitecoreContext();
     ContactUsModel=context.GetCurrentItem<ContactUs>();
     return View("~/Views/Content/ContactUs.cshtml",ContactUsModel);
 }