コード例 #1
0
        public async Task <DemoMenuItem[]> GetPrevNextMenu(string type, string currentTitle)
        {
            await InitializeAsync(CurrentLanguage);

            var items = Array.Empty <DemoMenuItem>();

            if (type.ToLowerInvariant() == "docs")
            {
                items        = _docMenuCache.TryGetValue(CurrentLanguage, out var menuItems) ? (await menuItems).OrderBy(x => x.Order).ToArray() : Array.Empty <DemoMenuItem>();
                currentTitle = $"docs/{currentTitle}";
            }
            else
            {
                items = _demoMenuCache.TryGetValue(CurrentLanguage, out var menuItems) ? (await menuItems)
                        .OrderBy(x => x.Order)
                        .SelectMany(x => x.Children)
                        .ToArray() : Array.Empty <DemoMenuItem>();

                currentTitle = $"components/{currentTitle}";
            }

            for (var i = 0; i < items.Length; i++)
            {
                if (currentTitle.Equals(items[i].Url, StringComparison.InvariantCultureIgnoreCase))
                {
                    var prev = i == 0 ? null : items[i - 1];
                    var next = i == items.Length - 1 ? null : items[i + 1];
                    return(new[] { prev, next });
                }
            }

            return(new DemoMenuItem[] { null, null });
        }
コード例 #2
0
        public async Task <DemoComponent> GetComponentAsync(string componentName)
        {
            await InitializeAsync(CurrentLanguage);

            return(_componentCache.TryGetValue(CurrentLanguage, out var component)
                ? (await component)[componentName.ToLower()]
                : null);
        }
コード例 #3
0
        public async Task <DemoMenuItem[]> GetMenuAsync()
        {
            await InitializeAsync(CurrentLanguage);

            return(_menuCache.TryGetValue(CurrentLanguage, out var menuItems) ? await menuItems : Array.Empty <DemoMenuItem>());
        }
コード例 #4
0
 public RenderFragment GetShowCase(string type)
 {
     return(_showCaseCache.TryGetValue(type, out var showCase) ? showCase : _defaultShowCase);
 }
コード例 #5
0
        public async ValueTask <RenderFragment> GetShowCase(string type)
        {
            await InitializeDemos();

            return(_showCaseCache.TryGetValue(type, out var showCase) ? showCase : _defaultShowCase);
        }