Пример #1
0
        public async Task <IHtmlContent> DisplayAsync(IView view)
        {
            if (view == null)
            {
                return(HtmlString.Empty);
            }

            // Build view descriptor
            //var viewDescriptor = _viewFactory.Create(view);

            // Get registered view adapter providers for the view
            if (_viewAdapterManager == null)
            {
                _viewAdapterManager = ViewContext.HttpContext.RequestServices.GetService <IViewAdapterManager>();
            }

            var viewAdapterResults = await _viewAdapterManager.GetViewAdaptersAsync(view.ViewName);

            // Invoke the view with supplied context
            return(await _viewFactory.InvokeAsync(new ViewDisplayContext()
            {
                ViewDescriptor = new ViewDescriptor()
                {
                    Name = view.ViewName,
                    View = view
                },
                ViewAdaptorResults = viewAdapterResults,
                ViewContext = ViewContext,
                ServiceProvider = _serviceProvider
            }));
        }