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 allTemplates = new TemplateRegistry <IRazorTemplate>();

            var razorSettings = new RazorEngineSettings();
            var razorSet      = razorSettings.Search;

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

            var viewPathPolicy = new ViewPathPolicy <IRazorTemplate>();

            allTemplates.Each(x =>
            {
                viewPathPolicy.Apply(x);
                x.Descriptor = new ViewDescriptor <IRazorTemplate>(x);
            });

            var commonNamespaces = new CommonViewNamespaces();

            commonNamespaces.AddForType <string>();
            _templateFactory = new TemplateFactoryCache(commonNamespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator());

            _pak1TemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.ByOrigin(Package2));
            _appTemplateRegistry  = new TemplateRegistry <IRazorTemplate>(allTemplates.FromHost());

            _serviceLocator = MockRepository.GenerateMock <IServiceLocator>();

            var sharingGraph = new SharingGraph();

            sharingGraph.Dependency("Package1", ContentFolder.Application);
            sharingGraph.Dependency("Package2", ContentFolder.Application);
            var templateDirectory = new TemplateDirectoryProvider <IRazorTemplate>(new SharedPathBuilder(), allTemplates,
                                                                                   sharingGraph);

            _sharedTemplateLocator = new SharedTemplateLocator <IRazorTemplate>(templateDirectory, allTemplates,
                                                                                new RazorTemplateSelector());

            var partialRenderer = new PartialRenderer(_sharedTemplateLocator, _templateFactory);

            _serviceLocator.Expect(x => x.GetInstance(Arg.Is(typeof(IPartialRenderer)))).Return(partialRenderer);
            _serviceLocator.Expect(x => x.GetInstance(typeof(IOutputWriter))).Return(MockRepository.GenerateMock <IOutputWriter>());
        }
 public SparkActivator(ISparkTemplateRegistry templateRegistry, ISparkViewEngine engine, CommonViewNamespaces namespaces, ITemplateDirectoryProvider <ITemplate> directoryProvider, SparkEngineSettings settings)
 {
     _templateRegistry  = templateRegistry;
     _engine            = engine;
     _namespaces        = namespaces;
     _directoryProvider = directoryProvider;
     _settings          = settings;
 }
Beispiel #3
0
 public SparkActivator(ISparkTemplateRegistry templateRegistry, ISparkViewEngine engine, CommonViewNamespaces namespaces, ITemplateDirectoryProvider<ITemplate> directoryProvider, SparkEngineSettings settings)
 {
     _templateRegistry = templateRegistry;
     _engine = engine;
     _namespaces = namespaces;
     _directoryProvider = directoryProvider;
     _settings = settings;
 }
 private void AddImport(CommonViewNamespaces commonViewNamespaces, Func<string> namespaceSelector)
 {
     var modelNamespace = namespaceSelector();
     if (!commonViewNamespaces.IgnoredNamespacesForAutoImport.Any(modelNamespace.StartsWith))
     {
         commonViewNamespaces.Add(modelNamespace);
     }
 }
Beispiel #5
0
 public TemplateFactoryCache(CommonViewNamespaces commonViewNamespaces,
                             RazorEngineSettings razorEngineSettings, ITemplateCompiler templateCompiler, RazorTemplateGenerator templateGenerator)
 {
     _commonViewNamespaces = commonViewNamespaces;
     _razorEngineSettings  = razorEngineSettings;
     _templateCompiler     = templateCompiler;
     _templateGenerator    = templateGenerator;
     _cache             = new Dictionary <string, Type>();
     _lastModifiedCache = new Cache <string, long>(name => name.LastModified());
 }
 public TemplateFactoryCache(CommonViewNamespaces commonViewNamespaces, 
     RazorEngineSettings razorEngineSettings, ITemplateCompiler templateCompiler, IRazorTemplateGenerator templateGenerator)
 {
     _commonViewNamespaces = commonViewNamespaces;
     _razorEngineSettings = razorEngineSettings;
     _templateCompiler = templateCompiler;
     _templateGenerator = templateGenerator;
     _cache = new Dictionary<string, Type>();
     _lastModifiedCache = new Cache<string, long>(name => name.LastModified());
 }
        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 allTemplates = new TemplateRegistry<IRazorTemplate>();

            var razorSettings = new RazorEngineSettings();
            var razorSet = razorSettings.Search;

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

            var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>();
            allTemplates.Each(x =>
            {
                viewPathPolicy.Apply(x);
                x.Descriptor = new ViewDescriptor<IRazorTemplate>(x);
            });

            var commonNamespaces = new CommonViewNamespaces();
            commonNamespaces.AddForType<string>();
            _templateFactory = new TemplateFactoryCache(commonNamespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator());

            _pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2));
            _appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost());

            _serviceLocator = MockRepository.GenerateMock<IServiceLocator>();

            var sharingGraph = new SharingGraph();
            sharingGraph.Dependency("Package1", ContentFolder.Application);
            sharingGraph.Dependency("Package2", ContentFolder.Application);
            var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates,
                                                                                  sharingGraph);
            _sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates,
                                                                               new RazorTemplateSelector());

            var partialRenderer = new PartialRenderer(_sharedTemplateLocator, _templateFactory);
            _serviceLocator.Expect(x => x.GetInstance(Arg.Is(typeof (IPartialRenderer)))).Return(partialRenderer);
            _serviceLocator.Expect(x => x.GetInstance(typeof (IOutputWriter))).Return(MockRepository.GenerateMock<IOutputWriter>());
        }
        protected override void beforeEach()
        {
            _viewEngine = new SparkViewEngine();
            _settings   = _viewEngine.Settings;

            var commonViewNamespaces = new CommonViewNamespaces();

            commonViewNamespaces.Add("Foo");
            commonViewNamespaces.Add("Bar");

            Services.Inject(commonViewNamespaces);

            Services.Inject <ISparkViewEngine>(_viewEngine);
            ClassUnderTest.Activate(Enumerable.Empty <IPackageInfo>(), MockFor <IPackageLog>());
        }
Beispiel #9
0
 protected abstract void addNamespacesForViews(CommonViewNamespaces namespaces);
Beispiel #10
0
 public override void ReadSharedNamespaces(CommonViewNamespaces namespaces)
 {
     // nothing
 }
Beispiel #11
0
 protected override void addNamespacesForViews(CommonViewNamespaces namespaces)
 {
     namespaces.AddForType <RazorViewFacility>(); // FubuMVC.Razor
     namespaces.AddForType <IPartialInvoker>();   // FubuMVC.Core.UI
 }
Beispiel #12
0
 public void ReadSharedNamespaces(CommonViewNamespaces namespaces)
 {
 }
Beispiel #13
0
 public override void ReadSharedNamespaces(CommonViewNamespaces namespaces)
 {
     namespaces.Namespaces.Each(x => _sparkSettings.AddNamespace(x));
 }
Beispiel #14
0
 protected override void addNamespacesForViews(CommonViewNamespaces namespaces)
 {
 }
Beispiel #15
0
 public RazorActivator(CommonViewNamespaces namespaces)
 {
     _namespaces = namespaces;
 }
 public void ReadSharedNamespaces(CommonViewNamespaces namespaces)
 {
     throw new NotImplementedException();
 }
Beispiel #17
0
 public void ReadSharedNamespaces(CommonViewNamespaces namespaces)
 {
     throw new NotImplementedException();
 }
        public SparkActivator (ISparkTemplateRegistry templateRegistry, ISparkViewEngine engine, CommonViewNamespaces namespaces)
		{
			_templateRegistry = templateRegistry;
			_engine = engine;
		    _namespaces = namespaces;
		}
Beispiel #19
0
 public abstract void ReadSharedNamespaces(CommonViewNamespaces namespaces);
 public void ReadSharedNamespaces(CommonViewNamespaces namespaces)
 {
 }
	    public RazorActivator (ITemplateServiceConfiguration engine, CommonViewNamespaces namespaces)
		{
		    _engine = engine;
		    _namespaces = namespaces;
		}