protected override void InitializeFileSystem(InMemoryVirtualPathProvider fileSystem) { base.InitializeFileSystem(fileSystem); fileSystem.WriteFile("/views/v1.cshtml", View1Html); fileSystem.WriteFile("/views/v2.cshtml", View2Html); fileSystem.WriteFile("/views/v3.cshtml", View3Html); }
public void OnBeforeEachTest() { RazorFormat.Instance = null; var fileSystem = new InMemoryVirtualPathProvider(new BasicAppHost()); fileSystem.WriteFile("/views/TheLayout.cshtml", LayoutHtml); InitializeFileSystem(fileSystem); RazorFormat = new RazorFormat { VirtualFileSources = fileSystem, PageBaseType = typeof(CustomRazorBasePage<>), EnableLiveReload = false, PrecompilePages = PrecompileEnabled, WaitForPrecompilationOnStartup = WaitForPrecompileEnabled, }.Init(); }
public override List<IVirtualPathProvider> GetVirtualPathProviders() { var existingProviders = base.GetVirtualPathProviders(); var memFs = new InMemoryVirtualPathProvider(this); //Get FileSystem Provider var fs = existingProviders.First(x => x is FileSystemVirtualPathProvider); //Process all .html files: foreach (var file in fs.GetAllMatchingFiles("*.html")) { var contents = Minifiers.HtmlAdvanced.Compress(file.ReadAllText()); memFs.AddFile(file.VirtualPath, contents); } //Process all .css files: foreach (var file in fs.GetAllMatchingFiles("*.css") .Where(file => !file.VirtualPath.EndsWith(".min.css"))) { var contents = Minifiers.Css.Compress(file.ReadAllText()); memFs.AddFile(file.VirtualPath, contents); } //Process all .js files foreach (var file in fs.GetAllMatchingFiles("*.js") .Where(file => !file.VirtualPath.EndsWith(".min.js"))) { try { var js = file.ReadAllText(); var contents = Minifiers.JavaScript.Compress(js); memFs.AddFile(file.VirtualPath, contents); } catch (Exception ex) { //Report any errors in StartUpErrors collection on ?debug=requestinfo base.OnStartupException(new Exception("JSMin Error in {0}: {1}".Fmt(file.VirtualPath, ex.Message))); } } //Give new Memory FS highest priority existingProviders.Insert(0, memFs); return existingProviders; }
public InMemoryVirtualDirectory(InMemoryVirtualPathProvider pathProvider, string dirPath, IVirtualDirectory parentDir = null) : base(pathProvider, parentDir) { this.pathProvider = pathProvider; this.DirPath = dirPath; }
public InMemoryVirtualDirectory(InMemoryVirtualPathProvider pathProvider, string dirPath) : base(pathProvider) { this.pathProvider = pathProvider; this.DirPath = dirPath; }
protected virtual void InitializeFileSystem(InMemoryVirtualPathProvider fileSystem) { }