Esempio n. 1
0
        private async Task <ViewEngineResult> GetViewResult(string controllerName, string viewName)
        {
            TemplateInfo templateInfo        = null;
            var          componentDefinition = await _componentRepository.GetComponentDefinitionByIdAsync(viewName).ConfigureAwait(false);

            if (componentDefinition != null)
            {
                templateInfo = componentDefinition.DefaultTemplate;
            }

            if (templateInfo == null)
            {
                templateInfo = await _templateRepository.GetTemplateAsync(viewName).ConfigureAwait(false);
            }

            if (templateInfo != null)
            {
                var modelType = await _modelTypeProvider.GetModelTypeFromTemplateAsync(templateInfo).ConfigureAwait(false);

                if (modelType == null)
                {
                    modelType = typeof(object);
                }

                var view = await _viewEngine.CreateViewAsync(templateInfo, modelType).ConfigureAwait(false);

                if (view != null)
                {
                    return(new ViewEngineResult(new NitroViewAdapter(CreateAdapter(view), ResolveContext), this));
                }
            }

            return(new ViewEngineResult(new[] { viewName, controllerName }));
        }
Esempio n. 2
0
 public static Task <IView> CreateViewAsync(this IViewEngine viewEngine, TemplateInfo templateInfo)
 {
     return(viewEngine.CreateViewAsync(templateInfo, typeof(object)));
 }
Esempio n. 3
0
 public Task <Type> GetModelTypeFromTemplateAsync(TemplateInfo templateInfo)
 {
     return(Task.FromResult(typeof(object)));
 }