Ejemplo n.º 1
0
 public void SetUp()
 {
     ServiceStackHost.Instance.VirtualPathProvider = pathProvider = new InMemoryVirtualPathProvider(new BasicAppHost());
     markdownFormat = new MarkdownFormat {
         VirtualPathProvider = pathProvider,
     };
 }
 public void SetUp()
 {
     EndpointHost.VirtualPathProvider = pathProvider = new InMemoryVirtualPathProvider(new BasicAppHost());
     markdownFormat = new MarkdownFormat {
         VirtualPathProvider = pathProvider,
     };
 }
 public void SetUp()
 {
     ServiceStackHost.Instance.VirtualFileSources = pathProvider = new MemoryVirtualFiles();
     markdownFormat = new MarkdownFormat
     {
         VirtualPathProvider = pathProvider,
     };
 }
        protected override void InitializeFileSystem(InMemoryVirtualPathProvider fileSystem)
        {
            base.InitializeFileSystem(fileSystem);

            fileSystem.AddFile("/views/v1.cshtml", View1Html);
            fileSystem.AddFile("/views/v2.cshtml", View2Html);
            fileSystem.AddFile("/views/v3.cshtml", View3Html);
        }
Ejemplo n.º 5
0
        public void SetUp()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");

            EndpointHost.VirtualPathProvider = pathProvider = new InMemoryVirtualPathProvider(new BasicAppHost());
            markdownFormat = new MarkdownFormat {
                VirtualPathProvider = pathProvider,
            };
        }
        public void OnBeforeEachTest()
        {
            RazorFormat.Instance = null;

            var fileSystem = new InMemoryVirtualPathProvider(new BasicAppHost());

            RazorFormat = new RazorFormat
            {
                VirtualPathProvider = fileSystem,
                EnableLiveReload    = false,
            }.Init();
        }
Ejemplo n.º 7
0
            public override List <IVirtualPathProvider> GetVirtualFileSources()
            {
                var existingProviders = base.GetVirtualFileSources();
                var memFs             = new InMemoryVirtualPathProvider();

                foreach (var entry in HtmlFiles)
                {
                    memFs.AppendFile(entry.Key, entry.Value);
                }

                existingProviders.Insert(0, memFs);
                return(existingProviders);
            }
Ejemplo n.º 8
0
            public override List <IVirtualPathProvider> GetVirtualFileSources()
            {
                var existingProviders = base.GetVirtualFileSources();
                var memFs             = new InMemoryVirtualPathProvider(this);

                memFs.WriteFile("/file.js", "console.log('foo')");
                memFs.WriteFile("/file.css", ".foo{}");
                memFs.WriteFile("/file.txt", "foo");
                memFs.WriteFile("/default.html", "<body>foo</body>");

                //Give new Memory FS highest priority
                existingProviders.Insert(0, memFs);
                return(existingProviders);
            }
Ejemplo n.º 9
0
        public void File_Copy_CrossProvider()
        {
            using (var otherProvider = new InMemoryVirtualPathProvider())
            {
                var file = Provider.CreateFile("test.txt", "test data");
                var dir  = otherProvider.CreateDirectory("FolderMove");

                var newFile = file.CopyTo(dir);

                Assert.That(newFile, Is.Not.Null);
                Assert.That(newFile.Directory, Is.EqualTo(dir));
                Assert.That(dir.GetFile("test.txt"), Is.EqualTo(newFile));
                Assert.That(Provider.GetFile("test.txt"), Is.Not.Null);
            }
        }
Ejemplo n.º 10
0
        public override List <IVirtualPathProvider> GetVirtualFileSources()
        {
            var existingProviders = base.GetVirtualFileSources();
            //return existingProviders;

            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.WriteFile(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.WriteFile(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.WriteFile(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);
        }
Ejemplo n.º 11
0
        public void OnBeforeEachTest()
        {
            RazorFormat.Instance = null;

            var fileSystem = new InMemoryVirtualPathProvider();

            fileSystem.WriteFile("/views/TheLayout.cshtml", LayoutHtml);
            InitializeFileSystem(fileSystem);

            RazorFormat = new RazorFormat
            {
                VirtualFileSources             = fileSystem,
                PageBaseType                   = typeof(CustomRazorBasePage <>),
                EnableLiveReload               = false,
                PrecompilePages                = PrecompileEnabled,
                WaitForPrecompilationOnStartup = WaitForPrecompileEnabled,
            }.Init();
        }
Ejemplo n.º 12
0
 protected virtual void InitializeFileSystem(InMemoryVirtualPathProvider fileSystem)
 {
 }