Exemplo n.º 1
0
        public async Task <PageModuleTypeFileDetails> ExecuteAsync(GetPageModuleTypeFileDetailsByFileNameQuery query, IExecutionContext executionContext)
        {
            var viewPath = _viewLocator.GetPathByFileName(query.FileName);

            if (string.IsNullOrEmpty(viewPath))
            {
                throw new FileNotFoundException($"Page module view file '{query.FileName}' not found.");
            }

            var view = await _viewFileReader.ReadViewFileAsync(viewPath);

            if (view == null)
            {
                throw new FileNotFoundException($"Page module view file '{query.FileName}' not found at location '{viewPath}'.");
            }

            var parsedData           = ParseViewFile(view);
            var pageTemplateFileInfo = new PageModuleTypeFileDetails();

            pageTemplateFileInfo.Name        = StringHelper.FirstNonEmpty(parsedData.Name, TextFormatter.PascalCaseToSentence(query.FileName));
            pageTemplateFileInfo.Description = parsedData.Description;
            pageTemplateFileInfo.Templates   = await MapChildTemplates(query.FileName);

            return(pageTemplateFileInfo);
        }
        public async Task <PageTemplateFileInfo> ExecuteAsync(GetPageTemplateFileInfoByPathQuery query, IExecutionContext executionContext)
        {
            var view = await _viewFileReader.ReadViewFileAsync(query.FullPath);

            if (view == null)
            {
                throw new FileNotFoundException("View file not found: " + query.FullPath);
            }

            var pageTemplateFileInfo = await ParseViewFile(view, true, executionContext);

            return(pageTemplateFileInfo);
        }