/// <inheritdoc /> public IRazorPage CreateInstance([NotNull] string relativePath) { if (relativePath.StartsWith("~/", StringComparison.Ordinal)) { // For tilde slash paths, drop the leading ~ to make it work with the underlying IFileSystem. relativePath = relativePath.Substring(1); } var fileInfo = _fileInfoCache.GetFileInfo(relativePath); if (fileInfo != null) { var relativeFileInfo = new RelativeFileInfo() { FileInfo = fileInfo, RelativePath = relativePath, }; var result = _compilerCache.GetOrAdd( relativeFileInfo, _isInstrumentationEnabled, () => RazorCompilationService.Compile(relativeFileInfo, _isInstrumentationEnabled)); var page = (IRazorPage)_activator.CreateInstance(_serviceProvider, result.CompiledType); page.Path = relativePath; return(page); } return(null); }
/// <inheritdoc /> public IRazorPage CreateInstance([NotNull] string path) { var fileInfo = _fileInfoCache.GetFileInfo(path); if (fileInfo != null) { var result = _compilationService.Compile(fileInfo); var page = (IRazorPage)_activator.CreateInstance(_serviceProvider, result.CompiledType); page.Path = path; return(page); } return(null); }