/// <summary> /// Builds the <see cref="DotvvmView"/> for the specified HTTP request, resolves the master page hierarchy and performs the composition. /// </summary> public DotvvmView BuildView(IDotvvmRequestContext context) { // get the page markup var markup = markupFileLoader.GetMarkupFileVirtualPath(context); // build the page var pageBuilder = controlBuilderFactory.GetControlBuilder(markup); var contentPage = pageBuilder.BuildControl(controlBuilderFactory) as DotvvmView; FillsDefaultDirectives(contentPage, context.Configuration); // check for master page and perform composition recursively while (IsNestedInMasterPage(contentPage)) { // load master page var masterPageFile = contentPage.Directives[ParserConstants.MasterPageDirective]; var masterPage = (DotvvmView)controlBuilderFactory.GetControlBuilder(masterPageFile).BuildControl(controlBuilderFactory); FillsDefaultDirectives(masterPage, context.Configuration); PerformMasterPageComposition(contentPage, masterPage); masterPage.ViewModelType = contentPage.ViewModelType; contentPage = masterPage; } // verifies the SPA request VerifySpaRequest(context, contentPage); return(contentPage); }
public bool BuildView(DotHtmlFileInfo file, out DotHtmlFileInfo masterPage) { masterPage = null; if (file.Status != CompilationState.NonCompilable) { try { var pageBuilder = controlBuilderFactory.GetControlBuilder(file.VirtualPath); var compiledControl = pageBuilder.builder.Value.BuildControl(controlBuilderFactory, dotvvmConfiguration.ServiceProvider); if (compiledControl is DotvvmView view && view.Directives.TryGetValue(ParserConstants.MasterPageDirective, out var masterPagePath)) { masterPage = masterPages.Value.GetOrAdd(masterPagePath, new DotHtmlFileInfo(masterPagePath)); } file.Status = CompilationState.CompletedSuccessfully; file.Exception = null; } catch (Exception e) { file.Status = CompilationState.CompilationFailed; file.Exception = e.Message; return(false); } } return(true); }
public DotvvmView BuildView(IDotvvmRequestContext context) { // get the page markup var markup = markupFileLoader.GetMarkupFileVirtualPath(context); // build the page var(_, pageBuilder) = controlBuilderFactory.GetControlBuilder(markup); var contentPage = (DotvvmView)pageBuilder.Value.BuildControl(controlBuilderFactory, context.Services); FillsDefaultDirectives(contentPage); // check for master page and perform composition recursively while (IsNestedInMasterPage(contentPage)) { // load master page var masterPageFile = contentPage.Directives ![ParserConstants.MasterPageDirective];
/// <summary> /// Finds the markup control. /// </summary> protected override IControlType FindMarkupControl(string file) { var(descriptor, controlBuilder) = controlBuilderFactory.GetControlBuilder(file); return(new ControlType(descriptor.ControlType, file, descriptor.DataContextType)); }
/// <summary> /// Finds the markup control. /// </summary> protected override IControlType FindMarkupControl(string file) { var controlBuilder = controlBuilderFactory.GetControlBuilder(file); return(new ControlType(controlBuilder.ControlType, controlBuilder.GetType(), file, controlBuilder.DataContextType)); }
/// <summary> /// Finds the markup control. /// </summary> protected virtual ControlType FindMarkupControl(string file) { var controlBuilder = controlBuilderFactory.GetControlBuilder(file); return(new ControlType(controlBuilder.ControlType, controlBuilder.GetType(), file)); }