Пример #1
0
 private void Button_OnClick(EMenu menu)
 {
     if (_txtMenu != null)
     {
         _txtMenu.text = menu.ToString();
     }
 }
Пример #2
0
        // -------------------------------------------------------------------- private methods

        private async Task <IList <Nav> > QueryMenuAsync(EMenu menuId, bool includeNavUrl = false)
        {
            // meta
            var meta = await metaRepository.GetAsync(menuId.ToString().ToLower(), EMetaType.Menu);

            if (meta == null)
            {
                // if not found create a meta
                meta = await metaRepository.CreateAsync(new Meta
                {
                    Key   = menuId.ToString().ToLower(),
                    Value = JsonConvert.SerializeObject(new List <Nav>()),
                    Type  = EMetaType.Menu,
                });
            }

            // navList
            var navList = JsonConvert.DeserializeObject <IList <Nav> >(meta.Value);

            // lookup nav
            foreach (var nav in navList)
            {
                try
                {
                    if (nav.Type == ENavType.CustomLink || !includeNavUrl)
                    {
                        continue;
                    }

                    var navProvider = navProviders.SingleOrDefault(p => p.CanProvideNav(nav.Type));
                    nav.Url = await navProvider.GetNavUrlAsync(nav.Id);

                    if (!nav.Url.StartsWith('/'))
                    {
                        nav.Url = $"/{nav.Url}";
                    }
                }
                catch (MokException ex) when(ex.ExceptionType == EExceptionType.ResourceNotFound)
                {
                    continue;
                }
            }

            return(navList);
        }
Пример #3
0
        private async Task UpdateMetaAsync(EMenu menuId, IList <Nav> navList)
        {
            var meta = await metaRepository.GetAsync(menuId.ToString(), EMetaType.Menu);

            meta.Value = JsonConvert.SerializeObject(navList);
            await metaRepository.UpdateAsync(meta);

            await InvalidateMenuCacheAsync(menuId);
        }