Example #1
0
        public ExtendedTester()
        {
            var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");

            var pathApp = Path.Combine(testRoot, "App");
            var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent");
            var pathPackage2 = Path.Combine(testRoot, "Package2");

            var templateRegistry = new TemplateRegistry<ITemplate>();
            var sparkSet = new SparkEngineSettings().Search;

            new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(sparkSet)
                .Union(new ContentFolder("Package1", pathPackage1).FindFiles(sparkSet)
                .Union(new ContentFolder("Package2", pathPackage2).FindFiles(sparkSet)))
                .Each(x =>
                {
                    if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) return;
                    templateRegistry.Register(new Template(x.Path, x.ProvenancePath, x.Provenance));
                });

            var viewPathPolicy = new ViewPathPolicy<ITemplate>();
            templateRegistry.Each(viewPathPolicy.Apply);

            _viewFolder = new TemplateViewFolder(templateRegistry);
            _engine = new SparkViewEngine
            {
                ViewFolder = _viewFolder,
                BindingProvider = new FubuBindingProvider(new SparkTemplateRegistry(templateRegistry))
            };

            _pak1TemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Package2));
            _appTemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.FromHost());
        }
        public BasicTester()
        {
            _hostRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");
            _pak1 = Path.Combine(_hostRoot, "Pak1");
            _pak2 = Path.Combine(_hostRoot, "Pak2");

            _hostHomeView = new Template(Path.Combine(_hostRoot, "Home", "Home.spark"), _hostRoot, TemplateConstants.HostOrigin);
            _hostApplicationView = new Template(Path.Combine(_hostRoot, "Shared", "application.spark"), _hostRoot, TemplateConstants.HostOrigin);
            _hostFooterPartialView = new Template(Path.Combine(_hostRoot, "Shared", "_footer.spark"), _hostRoot, TemplateConstants.HostOrigin);

            _pak1HomeView = new Template(Path.Combine(_pak1, "Home", "Home.spark"), _hostRoot, "Pak1");
            _pak1NamePartialView = new Template(Path.Combine(_pak1, "Home", "_name.spark"), _hostRoot, "Pak1");

            _pak2HomeView = new Template(Path.Combine(_pak2, "Home", "Home.spark"), _hostRoot, "Pak2");
            _pak2ApplicationView = new Template(Path.Combine(_pak2, "Shared", "application.spark"), _hostRoot, "Pak2");
            _pak2ThemeView = new Template(Path.Combine(_pak2, "Shared", "theme.spark"), _hostRoot, "Pak2");

            var templates = new List<ITemplate>
            {
                _hostHomeView, _hostApplicationView, _hostFooterPartialView,
                _pak1HomeView, _pak1NamePartialView,
                _pak2HomeView, _pak2ApplicationView, _pak2ThemeView
            };

            var viewPathPolicy = new ViewPathPolicy<ITemplate>();
            templates.Each(viewPathPolicy.Apply);

            _viewFolder = new TemplateViewFolder(new TemplateRegistry<ITemplate>(templates));
        }
Example #3
0
        public ExtendedTester()
        {
            var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");

            var pathApp = Path.Combine(testRoot, "App");
            var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent");
            var pathPackage2 = Path.Combine(testRoot, "Package2");

            var packages = new List<IPackageInfo>();
            var pack1 = new PackageInfo(Package1);
            var pack2 = new PackageInfo(Package2);
            pack1.RegisterFolder(BottleFiles.WebContentFolder, pathPackage1);
            pack2.RegisterFolder(BottleFiles.WebContentFolder, pathPackage2);
            packages.Add(pack1);
            packages.Add(pack2);

            var scanner = new TemplateFinder(new FileScanner(), packages) {HostPath = pathApp};

            var allTemplates = new TemplateRegistry();
            allTemplates.AddRange(scanner.FindInPackages());
            allTemplates.AddRange(scanner.FindInHost());

            var viewPathPolicy = new ViewPathPolicy();
            allTemplates.Each(viewPathPolicy.Apply);
            _viewFolder = new TemplateViewFolder(allTemplates);
            _engine = new SparkViewEngine
            {
                ViewFolder = _viewFolder,
                BindingProvider = new FubuBindingProvider(new TemplateRegistry(allTemplates))
            };

            _pak1TemplateRegistry = new TemplateRegistry(allTemplates.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry(allTemplates.ByOrigin(Package2));
            _appTemplateRegistry = new TemplateRegistry(allTemplates.FromHost());
        }