In Memory Virtual Path Provider.
Inheritance: ServiceStack.VirtualPath.AbstractVirtualPathProviderBase, IVirtualFiles, IWriteableVirtualPathProvider
コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: RazorEngineTests.cs プロジェクト: AVee/ServiceStack
        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();
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: rsnzh/ServiceStack
        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;
        }
コード例 #4
0
 public InMemoryVirtualDirectory(InMemoryVirtualPathProvider pathProvider, string dirPath, IVirtualDirectory parentDir = null)
     : base(pathProvider, parentDir)
 {
     this.pathProvider = pathProvider;
     this.DirPath      = dirPath;
 }
コード例 #5
0
 public InMemoryVirtualDirectory(InMemoryVirtualPathProvider pathProvider, string dirPath) 
     : base(pathProvider)
 {
     this.pathProvider = pathProvider;
     this.DirPath = dirPath;
 }
コード例 #6
0
ファイル: RazorEngineTests.cs プロジェクト: AVee/ServiceStack
 protected virtual void InitializeFileSystem(InMemoryVirtualPathProvider fileSystem)
 {
 }
コード例 #7
0
 public InMemoryVirtualDirectory(InMemoryVirtualPathProvider pathProvider, string dirPath)
     : base(pathProvider)
 {
     this.pathProvider = pathProvider;
     this.DirPath      = dirPath;
 }