コード例 #1
0
        public MenuViewModel Build(CachedMenu cachedMenu)
        {
            IEnumerable<CachedMenuItem> cachedMenuItems = new CachedMenuItem[] { };

              if (!string.IsNullOrEmpty(cachedMenu.CachedMenuItems))
            cachedMenuItems = JsonConvert.DeserializeObject<IEnumerable<CachedMenuItem>>(cachedMenu.CachedMenuItems);

              return new MenuViewModel()
              {
            MenuItems = cachedMenuItems.OrderBy(cmi => cmi.Position).Select(
              cmi => new MenuItemViewModelBuilder(this.handler).Build(cmi)
            )
              };
        }
コード例 #2
0
        private CachedMenuItem CacheMenuItem(Culture culture, MenuItem menuItem)
        {
            List<CachedMenuItem> cachedChildMenuItems = new List<CachedMenuItem>();

              foreach (MenuItem childMenuItem in this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuItemId(menuItem.Id))
            cachedChildMenuItems.Add(this.CacheMenuItem(culture, childMenuItem));

              CachedMenuItem cachedMenuItem = new CachedMenuItem();

              cachedMenuItem.MenuItemId = menuItem.Id;
              cachedMenuItem.Name = this.GetLocalizationValue(culture.Id, menuItem.NameId);
              cachedMenuItem.Url = menuItem.Url;
              cachedMenuItem.Position = menuItem.Position;

              if (cachedChildMenuItems.Count != 0)
            cachedMenuItem.CachedMenuItems = this.SerializeObject(cachedChildMenuItems);

              return cachedMenuItem;
        }