private static void AddViewFolder(SparkSettings result)
 {
     result.AddViewFolder(ViewFolderType.VirtualPathProvider,
                          new Dictionary <string, string> {
         { "virtualBaseDir", "~/views/" }
     });
 }
Пример #2
0
        public void SettingsAreMergedRightToLeft()
        {
            var left = new SparkSettings();
            var right = new SparkSettings();

            right.NullBehaviour = NullBehaviour.Strict;
            right.PageBaseType = "test";
            right.Prefix = "test";
            right.StatementMarker = "T";
            right.AutomaticEncoding = true;
            right.AddResourceMapping("test", "test");
            right.AddAssembly("test");
            right.AddNamespace("test");
            right.AddViewFolder(typeof (int), new Dictionary<string, string>());

            Merger.Merge(left, right);

            left.NullBehaviour.ShouldEqual(right.NullBehaviour);
            left.NullBehaviour.ShouldEqual(right.PageBaseType);
            left.NullBehaviour.ShouldEqual(right.Prefix);
            left.NullBehaviour.ShouldEqual(right.StatementMarker);
            left.NullBehaviour.ShouldEqual(right.AutomaticEncoding);
            left.ResourceMappings.ShouldEqual(right.ResourceMappings);
            left.UseAssemblies.ShouldEqual(right.UseAssemblies);
            left.UseNamespaces.ShouldEqual(right.UseNamespaces);
        }
        public ConfigureSparkSettingsExpression AddViewFolder(string virtualFolderRoot)
        {
            if (!_settings.ViewFolders.Any(f => f.Parameters.ContainsKey(ViewFolderParam) && f.Parameters[ViewFolderParam] == virtualFolderRoot))
            {
                _settings.AddViewFolder(ViewFolderType.VirtualPathProvider, new Dictionary <string, string> {
                    { ViewFolderParam, virtualFolderRoot }
                });
            }

            return(this);
        }
        public ISparkSettings CreateSettings()
        {
            var settings = new SparkSettings
            {
                PageBaseType = typeof(SparkResourceView).Name
            };

            settings.AddViewFolder(typeof(TestingViewFolder), new Dictionary <string, string>
            {
                { "templateSource", _templateSource }
            });
            new SparkCodecNamespacesConfiguration().AddNamespaces(settings);
            settings.AddNamespace("OpenRasta.Codecs.Spark.Tests.TestObjects");
            return(settings);
        }
Пример #5
0
        public void EngineGetsCustomServiceAndViewFolderSettings()
        {
            var settings = new SparkSettings();

            settings.AddViewFolder(typeof(TestViewFolder),
                                   new Dictionary <string, string> {
                { "testpath", Path.Combine("hello", "world.spark") }
            });

            var container = new SparkServiceContainer(settings);

            container.SetServiceBuilder <IViewActivatorFactory>(c => new TestActivatorFactory());

            var engine = container.GetService <ISparkViewEngine>();

            Assert.IsInstanceOf(typeof(TestActivatorFactory), engine.ViewActivatorFactory);

            Assert.IsTrue(engine.ViewFolder.HasView(Path.Combine("hello", "world.spark")));
        }
 private void SetTemplateSource(string templateSource)
 {
     var settings = new SparkSettings
                     {
                         PageBaseType = typeof (SparkResourceView).Name
                     };
     settings.AddViewFolder(typeof (TestingViewFolder), new Dictionary<string, string>
                                                         {
                                                             {"templateSource", templateSource}
                                                         });
     settings.AddNamespace("OpenRasta.Codecs.Spark");
     settings.AddNamespace("OpenRasta.Web.Markup");
     settings.AddNamespace("OpenRasta.Web");
     settings.AddNamespace("OpenRasta.Codecs.Spark.Tests.TestObjects");
     settings.AddNamespace("System.Collections.Generic");
     settings.AddNamespace("OpenRasta.Codecs.Spark.Extensions");
     sparkConfiguration
         .Container
         .SetService<ISparkSettings>(settings);
 }
        public void EngineGetsCustomServiceAndViewFolderSettings()
        {
            var settings = new SparkSettings();
            settings.AddViewFolder(typeof(TestViewFolder),
                                   new Dictionary<string, string> { { "testpath", "hello\\world.spark" } });

            var container = new SparkServiceContainer(settings);
            container.SetServiceBuilder<IViewActivatorFactory>(c=>new TestActivatorFactory());

            var engine = container.GetService<ISparkViewEngine>();
            Assert.IsInstanceOfType(typeof(TestActivatorFactory), engine.ViewActivatorFactory);

            Assert.IsTrue(engine.ViewFolder.HasView("hello\\world.spark"));
        }