Exemplo n.º 1
0
        /// <summary>
        /// Method uses displayTemplateClient to resolve which display template should be displayed
        /// based on current context
        /// </summary>
        /// <param name="type">Target type (Item, Category)</param>
        /// <param name="displayObject">The display object.</param>
        /// <returns>display template name</returns>
        private string GetDisplayTemplate(TargetTypes type, object displayObject)
        {
            // set the context variable
            var set = UserHelper.CustomerSession.GetCustomerTagSet();

            //Add Tags for category
            switch (type)
            {
            case TargetTypes.Category:
                var category = displayObject as CategoryBase;
                if (category != null)
                {
                    set.Add(AppConfigContext.CategoryId, new Tag(category.CategoryId));
                }
                break;

            case TargetTypes.Item:
                var item = displayObject as Item;
                if (item != null)
                {
                    set.Add(AppConfigContext.ItemId, new Tag(item.ItemId));
                    set.Add(AppConfigContext.ItemType, new Tag(item.GetType().Name));
                }
                break;
            }

            var viewName = _templateClient.GetDisplayTemplate(type, set);

            return(string.IsNullOrEmpty(viewName) ? type.ToString() : viewName);
        }
        /// <summary>
        /// Gets the display template.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="tags">The tags.</param>
        /// <returns></returns>
        public string GetDisplayTemplate(TargetTypes target, TagSet tags)
        {
            var session = _customerSession.CustomerSession;
            var tagsLocal = tags ?? session.GetCustomerTagSet();

            return Helper.Get(
                string.Format(DisplayTemplateCacheKey, target.ToString(), tagsLocal.GetCacheKey()),
                () => _service.GetTemplate(target, tags),
                AppConfigConfiguration.Instance.Cache.DisplayTemplateMappingsTimeout,
                IsEnabled);
        }
Exemplo n.º 3
0
 public static string MapTarget(TargetTypes type)
 {
     return type.ToString().Replace("_", "-");
 }
Exemplo n.º 4
0
 public static string MapTarget(TargetTypes type)
 {
     return(type.ToString().Replace("_", "-"));
 }
Exemplo n.º 5
0
		/// <summary>
		/// Method uses displayTemplateClient to resolve which display template should be displayed
		/// based on current context
		/// </summary>
		/// <param name="type">Target type (Item, Category)</param>
		/// <param name="displayObject">The display object.</param>
		/// <returns>display template name</returns>
        private string GetDisplayTemplate(TargetTypes type, object displayObject)
        {
            // set the context variable
            var set = UserHelper.CustomerSession.GetCustomerTagSet();

            //Add Tags for category
            switch (type)
            {
                case TargetTypes.Category:
                    var category = displayObject as CategoryBase;
                    if (category != null)
                    {
                        set.Add(AppConfigContext.CategoryId, new Tag(category.CategoryId));
                    }
                    break;
                case TargetTypes.Item:
                    var item = displayObject as Item;
                    if (item != null)
                    {
                        set.Add(AppConfigContext.ItemId, new Tag(item.ItemId));
                        set.Add(AppConfigContext.ItemType, new Tag(item.GetType().Name));
                    }
                    break;
            }

            var viewName = _templateClient.GetDisplayTemplate(type, set);
            return string.IsNullOrEmpty(viewName) ? type.ToString() : viewName;
        }