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}"); }
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}"); }
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)); }
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)); }
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"); }
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}"); }
private static string CunstructMessage(ITemplatedItem item, ILiquidTemplateFinderStrategy strategy) { return($"invalid templated item : {item.GetType().Name} for strategy : {strategy.GetType().Name}"); }
public InvalidITempatedItemException(ITemplatedItem item, ILiquidTemplateFinderStrategy categoryTemplateFinderStrategy) : base(CunstructMessage(item, categoryTemplateFinderStrategy)) { }
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"); }
public string GetTemplatePathDefault(ITemplatedItem item = null) { return("tag-product"); }
public string GetTemplatePathByConvention(ITemplatedItem item) { return($"Product/tag-product-{item.Handle}"); }
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}"); }
public string GetTemplatePathByConvention(ITemplatedItem item = null) { var searchResult = item as EntitySearchResaultLiquidAdapted; return($"search-{searchResult.Scheme.Handle}"); }
public string GetTemplatePathDefault(ITemplatedItem item) { return($"user-profile"); }
public string GetTemplatePathDefault(ITemplatedItem item) { CheckCorrectType(item); return(GetTemplate(item)); }
public string GetTemplatePathByConvention(ITemplatedItem item = null) { return(GetTemplatePathDefault(item)); }
public string GetTemplatePathByConvention(ITemplatedItem item) { return($"UserProfiles/user-profile-{item.Handle}"); }
public string GetTemplatePathByConvention(ITemplatedItem item = null) { return("index"); }
private Template GetParsedTemplate(ITemplatedItem model) { return(Template.Parse(LiquidTemplateProvider.GetTemplateString(model))); }
public string GetTemplatePathDefault(ITemplatedItem item = null) { return("index"); }