Пример #1
0
 public void LocateEmbeddedFiles()
 {
     var viewFolder = new EmbeddedViewFolder(Assembly.Load("Spark.Tests"), "Spark.Tests.FileSystem.Embedded");
     Assert.IsTrue(viewFolder.HasView(Path.Combine("Home", "Index.spark")));
     Assert.IsFalse(viewFolder.HasView(Path.Combine("Home", "NoSuchFile.spark")));
     Assert.IsFalse(viewFolder.HasView("Home"));
     Assert.IsTrue(viewFolder.HasView(Path.Combine("Shared", "Default.spark")));
 }
Пример #2
0
        private void RegisterViewFolders(Assembly assembly, SparkViewFactory sparkViewFactory)
        {
            var viewFolder = new EmbeddedViewFolder(assembly, assembly.GetName().Name + ".Mvc.Views");

            sparkViewFactory.ViewFolder = sparkViewFactory.ViewFolder
                .Append(new SubViewFolder(viewFolder, AreaName))
                .Append(new SubViewFolder(viewFolder, "Shared\\" + AreaName));
        }
Пример #3
0
        public void RegisterStandardViewFolders(ICollection<IViewEngine> viewEngines, Assembly assembly, string areaName)
        {
            var viewFolder = new EmbeddedViewFolder(assembly, assembly.GetName().Name + ".Views");
            var sparkViewFactory = viewEngines.OfType<SparkViewFactory>().First();

            sparkViewFactory.ViewFolder = sparkViewFactory.ViewFolder
                .Append(new SubViewFolder(viewFolder, areaName))
                .Append(new SubViewFolder(viewFolder, "Shared\\" + areaName));
        }
Пример #4
0
        public SparkRender()
        {
            _viewFolder = new EmbeddedViewFolder(typeof (SparkRender).Assembly, "klinger.views");

            _engine = new SparkViewEngine
                          {
                              DefaultPageBaseType = typeof (VoteView).FullName,
                              ViewFolder = _viewFolder
                          };
        }
Пример #5
0
        protected override void RegisterArea(AreaRegistrationContext context, Assembly assembly, SparkViewFactory sparkViewFactory)
        {
            context.Routes.Add(new Route("assets/default/{*resource}",
                new RouteValueDictionary(),
                new RouteValueDictionary(),
                new EmbeddedContentRouteHandler(assembly, assembly.GetName().Name + ".Mvc.DefaultTemplate.Assets")));

            context.Routes.Add(new Route("services/templates/bbcode", new BBCodeRouteHandler()));

            var viewFolder = new EmbeddedViewFolder(assembly, assembly.GetName().Name + ".Mvc.DefaultTemplate.Views");

            sparkViewFactory.ViewFolder = sparkViewFactory.ViewFolder
                .Append(viewFolder);
        }
Пример #6
0
        public void ListViewsSameResults()
        {
            var filesystem = new FileSystemViewFolder(Path.Combine("FileSystem", "Embedded"));
            Assert.IsTrue(filesystem.HasView(Path.Combine("Home", "Index.spark")));

            var files = filesystem.ListViews("Home");
            Assert.AreEqual(2, files.Count);
            Assert.That(files.Any(f => Path.GetFileName(f) == "Index.spark"));
            Assert.That(files.Any(f => Path.GetFileName(f) == "List.spark"));

            var embedded = new EmbeddedViewFolder(Assembly.Load("Spark.Tests"), "Spark.Tests.FileSystem.Embedded");
            files = embedded.ListViews("home");
            Assert.AreEqual(2, files.Count);
            Assert.That(files.Any(f => Path.GetFileName(f) == "Index.spark"));
            Assert.That(files.Any(f => Path.GetFileName(f) == "List.spark"));
        }
Пример #7
0
        public void ComponentRenderViewFromEmbeddedResource()
        {
            viewComponentFactory.Registry.AddViewComponent("UseEmbeddedViews", typeof(UseEmbeddedViews));

            var embeddedViewFolder = new EmbeddedViewFolder(
                Assembly.Load("Castle.MonoRail.Views.Spark.Tests"),
                "Castle.MonoRail.Views.Spark.Tests.EmbeddedViews");

            engine.ViewFolder = engine.ViewFolder.Append(embeddedViewFolder);

            mocks.ReplayAll();

            var writer = new StringWriter();
            factory.Process("Home\\ComponentRenderViewFromEmbeddedResource.spark", writer, engineContext, controller, controllerContext);

            mocks.VerifyAll();

            var content = writer.ToString();
            Assert.That(content.Contains("<p>This was embedded</p>"));
        }
Пример #8
0
        static void RegisterViewFolders(IEnumerable<IViewEngine> viewEngines, Assembly assembly, string service)
        {
            if (service == null)
              {
            return;
              }

              var viewFolder = new EmbeddedViewFolder(assembly, assembly.GetName().Name + ".UI.Views");
              var sparkViewFactory = viewEngines.OfType<SparkViewFactory>().First();

              sparkViewFactory.ViewFolder = sparkViewFactory.ViewFolder
            .Append(new SubViewFolder(viewFolder, service))
            .Append(new SubViewFolder(viewFolder, "Shared\\" + service));
        }