コード例 #1
0
        public void CompileDependencies(IEnumerable <IPackageInfo> packages, IPackageLog log)
        {
            var provenances = packages.Select(p => p.Name).Union(new[] { TemplateConstants.HostOrigin }).ToArray();

            log.Trace("Compiling dependencies for [{0}]", provenances.Join(", "));

            _graph.CompileDependencies(provenances);
        }
コード例 #2
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 globalPackage = Path.Combine(testRoot, "Global");

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

            _sharingGraph = new SharingGraph();
            _sharingGraph.Global("Global");
            _sharingGraph.CompileDependencies("Package1", "Package2");

            new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(sparkSet)
                .Union(new ContentFolder("Package1", pathPackage1).FindFiles(sparkSet)
                .Union(new ContentFolder("Package2", pathPackage2).FindFiles(sparkSet)
                .Union(new ContentFolder("Global", globalPackage).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);
            _templateDirectoryProvider = new TemplateDirectoryProvider<ITemplate>(new SharedPathBuilder(), templateRegistry, _sharingGraph);
            _engine = new SparkViewEngine
            {
                ViewFolder = _viewFolder,
                BindingProvider = new FubuBindingProvider(new SparkTemplateRegistry(templateRegistry)),
                PartialProvider = new FubuPartialProvider(_templateDirectoryProvider)
            };

            _pak1TemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Package2));
            _appTemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.FromHost());
            _globalTemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Global));
        }