/// <summary> /// Resolves the view model for the root node. /// </summary> protected virtual ITypeDescriptor ResolveViewModelType(IReadOnlyDictionary <string, IReadOnlyList <IAbstractDirective> > directives, DothtmlRootNode root, string fileName) { if (!directives.ContainsKey(ParserConstants.ViewModelDirectiveName) || directives[ParserConstants.ViewModelDirectiveName].Count == 0) { root.AddError($"The @viewModel directive is missing in the page '{fileName}'!"); return(null); } var viewmodelDirective = (IAbstractViewModelDirective)directives[ParserConstants.ViewModelDirectiveName].First(); return(viewmodelDirective.ResolvedType); }
/// <summary> /// Resolves the view model for the root node. /// </summary> protected virtual ITypeDescriptor ResolveViewModelType(IReadOnlyDictionary <string, IReadOnlyList <IAbstractDirective> > directives, DothtmlRootNode root, string fileName) { if (!directives.ContainsKey(ParserConstants.ViewModelDirectiveName) || directives[ParserConstants.ViewModelDirectiveName].Count == 0) { root.AddError($"The @viewModel directive is missing in the page '{fileName}'!"); return(null); } var viewmodelDirective = directives[ParserConstants.ViewModelDirectiveName].First(); var viewModelType = FindType(viewmodelDirective.Value); if (viewModelType == null) { viewmodelDirective.DothtmlNode.AddError($"The type '{viewmodelDirective.Value}' required in the @viewModel directive was not found!"); } return(viewModelType); }