Ejemplo n.º 1
0
 private void CheckCorrectType(ITemplatedItem item)
 {
     if (!(item is CategoryLiquidViewModel))
     {
         throw new InvalidITempatedItemException(item, this);
     }
 }
 private void CheckTypeCorrection(ITemplatedItem item)
 {
     if (!(item is EntityLiquidAdapter))
     {
         throw new InvalidITempatedItemException(item, this);
     }
 }
        protected void AddToJournal([NotNull] ITemplatedItem item)
        {
            Debug.ArgumentNotNull(item, nameof(item));

            var treeViewItem = GetTreeViewItem(item.ItemUri, item.Name, item.Icon, item.TemplateId, item.TemplateName);

            if (treeViewItem == null)
            {
                return;
            }

            for (var n = recentItems.Count - 1; n >= 0; n--)
            {
                var recentItem = recentItems[n];

                if (recentItem.ItemUri == item.ItemUri)
                {
                    recentItems.Remove(recentItem);
                    Items.Remove(recentItem);
                }
            }

            recentItems.Add(treeViewItem);

            Insert(0, treeViewItem);

            while (recentItems.Count > MaxItems)
            {
                Items.RemoveAt(0);
                recentItems.RemoveAt(0);
            }

            Save();
        }
 public string GetTemplatePathByConvention(ITemplatedItem item = null)
 {
     if (!(item is UserEntitiesPaginatedLiquidAdapted adapted))
     {
         throw new InvalidITempatedItemException(item, this);
     }
     return($"User/user-{adapted.User.Handle}-{adapted.Scheme.Handle}");
 }
Ejemplo n.º 5
0
        public string GetTemplatePathByConvention(ITemplatedItem item = null)
        {
            if (!(item is ProductLiquidAdapter product))
            {
                throw new InvalidITempatedItemException(item, this);
            }

            return("product-" + product.Handle);
        }
        public string GetTemplatePathDefault(ITemplatedItem item)
        {
            if (!(item is Widget widget))
            {
                throw new NullReferenceException("invalid or null Entity passed for finding template");
            }

            return(GetTemplate(widget));
        }
        public string GetTemplatePathByConvention(ITemplatedItem item)
        {
            if (!(item is Widget widget))
            {
                throw new NullReferenceException("invalid or null Entity passed for finding template");
            }

            return($"Widgets/widget-{widget.Handle}");
        }
Ejemplo n.º 8
0
        private string GetTemplate(ITemplatedItem item)
        {
            var cat  = item as CategoryLiquidViewModel;
            var path = $"Category/{CreateExpectedFileNameForCateory(cat)}";

            return(File.Exists(_base + path + _extension)
                ? path
                : cat.Parent == null
                ? $"category-{cat.Scheme.Handle}"
                : GetTemplatePathDefault(cat.Parent));
        }
Ejemplo n.º 9
0
 public string GetTemplatePathDefault(ITemplatedItem item)
 {
     if (!(item is EntityTagLiquidViewModel tag))
     {
         throw new InvalidITempatedItemException(item, this);
     }
     if (tag.EntityScheme == null)
     {
         return(FindWithoutScheme(tag));
     }
     return(FindWithScheme(tag));
 }
Ejemplo n.º 10
0
        public string GetTemplatePathDefault(ITemplatedItem item = null)
        {
            if (!(item is ProductLiquidAdapter product))
            {
                throw new InvalidITempatedItemException(item, this);
            }

            if (product.Type == ProductType.Grouped && File.Exists(_base + "product-grouped" + _extension))
            {
                return("product-grouped");
            }

            return("product");
        }
Ejemplo n.º 11
0
        public string GetTemplateString(ITemplatedItem item)
        {
            var finderStrategy = _finderFactory.GetStrategy(item);
            var templatePath   = TemplatesBasePath + finderStrategy.GetTemplatePathByConvention(item) + Extension;

            if (!File.Exists(templatePath))
            {
                templatePath = TemplatesBasePath + finderStrategy.GetTemplatePathDefault(item) + Extension;
            }
            if (string.IsNullOrEmpty(templatePath))
            {
                throw new InvalidOperationException($"liquid viewnot found for {item.GetType()} handle => {item.Handle}");
            }
            return(GetTemplateString(templatePath));
        }
        private string GetTemplate(ITemplatedItem item)
        {
            var entity = (EntityLiquidAdapter)item;
            var templatePathByPrimaryCat = string.Empty;
            var cat = entity.Entity.PrimaryCategory;

            while (cat != null)
            {
                templatePathByPrimaryCat = $"{CreateExpectedFileNameForEntityWithPrimaryCat(entity, cat)}";
                if (cat.ParentId.HasValue && !File.Exists(_base + templatePathByPrimaryCat + _extension))
                {
                    cat = _container.GetInstance <IUnitOfWork>().Set <Category>().FirstOrDefault(x => x.Id == cat.ParentId);
                }
                else
                {
                    break;
                }
            }


            return(File.Exists(_base + templatePathByPrimaryCat + _extension)
                ? templatePathByPrimaryCat
                : $"single-{entity.Scheme.Handle}");
        }
 public string GetTemplatePathDefault(ITemplatedItem item = null)
 {
     return("product-category");
 }
 public string GetTemplatePathByConvention(ITemplatedItem item = null)
 {
     return($"product-category-{item.Handle}");
 }
Ejemplo n.º 15
0
 private static string CunstructMessage(ITemplatedItem item, ILiquidTemplateFinderStrategy strategy)
 {
     return($"invalid templated item : {item.GetType().Name} for strategy : {strategy.GetType().Name}");
 }
Ejemplo n.º 16
0
 public InvalidITempatedItemException(ITemplatedItem item, ILiquidTemplateFinderStrategy categoryTemplateFinderStrategy) : base(CunstructMessage(item, categoryTemplateFinderStrategy))
 {
 }
Ejemplo n.º 17
0
        public ILiquidTemplateFinderStrategy GetStrategy(ITemplatedItem item = null)
        {
            if (item is UserLiquidViewModel)
            {
                return(new UserProfileTemplateFinderStrategy());
            }

            if (item is PageLiquidViewModel)
            {
                return(new PageTemplateFinderStrategy());
            }

            if (item is EntityLiquidAdapter)
            {
                return(new EntityTemplateFinderStrategy(_container));
            }

            if (item is WidgetLiquidViewModel || item is Widget)
            {
                return(new WidgetTemplateFinderStrategy());
            }

            if (item is EntityTagLiquidViewModel)
            {
                return(new EntityTagTemplateFinderStrategy());
            }

            if (item is PageTagLiquidViewModel)
            {
                return(new PageTagTemplateFinderStrategy());
            }

            if (item is ProductTagLiquidViewModel)
            {
                return(new ProductTagTemplateFinderStrategy());
            }

            if (item is CategoryLiquidViewModel)
            {
                return(new CategoryTemplateFinderStrategy());
            }

            if (item is EntitySearchResaultLiquidAdapted)
            {
                return(new EntitySearchTemplateFinderStrategy());
            }

            if (item is UserEntitiesPaginatedLiquidAdapted)
            {
                return(new UserCreatedEntityTemplateFinderStrategy());
            }
            if (item is ProductLiquidAdapter)
            {
                return(new ProductTeplateFinderStrategy());
            }

            if (item is ProductCategoryLiquidVeiwModel)
            {
                return(new ProductCategoryTeplateFinderStrategy());
            }

            if (item is UserCartLiquidViewModel)
            {
                return(new UserCartTeplateFinderStrategy());
            }

            if (item is OrderLiquidViewModel)
            {
                return(new OrderTemplateFinderStrategy());
            }

            return(null);
        }
 public string GetTemplatePathDefault(ITemplatedItem item)
 {
     return($"page");
 }
Ejemplo n.º 19
0
 public string GetTemplatePathDefault(ITemplatedItem item = null)
 {
     return("tag-product");
 }
Ejemplo n.º 20
0
 public string GetTemplatePathByConvention(ITemplatedItem item)
 {
     return($"Product/tag-product-{item.Handle}");
 }
Ejemplo n.º 21
0
        public static void OpenUsingDefaultAction([NotNull] ITemplatedItem item)
        {
            Assert.ArgumentNotNull(item, nameof(item));

            DefaultActionPipeline.Run().WithParameters(new ItemSelectionContext(item));
        }
 public string GetTemplatePathByConvention(ITemplatedItem item)
 {
     return($"Page/tag-page-{item.Handle}");
 }
Ejemplo n.º 23
0
        public string GetTemplatePathByConvention(ITemplatedItem item = null)
        {
            var searchResult = item as EntitySearchResaultLiquidAdapted;

            return($"search-{searchResult.Scheme.Handle}");
        }
Ejemplo n.º 24
0
 public string GetTemplatePathDefault(ITemplatedItem item)
 {
     return($"user-profile");
 }
Ejemplo n.º 25
0
 public string GetTemplatePathDefault(ITemplatedItem item)
 {
     CheckCorrectType(item);
     return(GetTemplate(item));
 }
Ejemplo n.º 26
0
 public string GetTemplatePathByConvention(ITemplatedItem item = null)
 {
     return(GetTemplatePathDefault(item));
 }
Ejemplo n.º 27
0
 public string GetTemplatePathByConvention(ITemplatedItem item)
 {
     return($"UserProfiles/user-profile-{item.Handle}");
 }
 public string GetTemplatePathByConvention(ITemplatedItem item = null)
 {
     return("index");
 }
Ejemplo n.º 29
0
 private Template GetParsedTemplate(ITemplatedItem model)
 {
     return(Template.Parse(LiquidTemplateProvider.GetTemplateString(model)));
 }
 public string GetTemplatePathDefault(ITemplatedItem item = null)
 {
     return("index");
 }