Ejemplo n.º 1
0
        public async Task InitializeDemos()
        {
            if (_showCaseCache == null)
            {
                _showCaseCache = new ConcurrentCache <string, RenderFragment>();

                var baseUrl   = _navigationManager.ToAbsoluteUri(_navigationManager.BaseUri);
                var demoTypes = await _httpClient.GetFromJsonAsync <string[]>(new Uri(baseUrl, $"_content/AntDesign.Docs/meta/demos.json").ToString());

                foreach (var type in demoTypes)
                {
                    _showCaseCache.GetOrAdd(type, t =>
                    {
                        void ShowCase(RenderTreeBuilder builder)
                        {
                            var showCase = Type.GetType($"{Assembly.GetExecutingAssembly().GetName().Name}.{type}");
                            builder.OpenComponent(0, showCase);
                            builder.CloseComponent();
                        }

                        return(ShowCase);
                    });
                }
            }
        }