Пример #1
0
        private static Tuple <IEngineCore, IPageLookup> CreateDefaultDependencies(
            ITemplateManager manager,
            IEngineConfiguration configuration)
        {
            IEngineCore core = new EngineCore(manager, configuration);

            IPageFactoryProvider pageFactory = new DefaultPageFactory(core.KeyCompile);
            IPageLookup          lookup      = new DefaultPageLookup(pageFactory);

            return(new Tuple <IEngineCore, IPageLookup>(core, lookup));
        }
Пример #2
0
        /// <summary>
        /// Creates a <see cref="RazorLightEngine"/> that resolves templates by searching
        /// them on physical storage with a given <see cref="IEngineConfiguration"/>
        /// and tracks file changes with <seealso cref="System.IO.FileSystemWatcher"/>
        /// </summary>
        /// <param name="root">Root folder where views are stored</param>
        /// <param name="configuration">Engine configuration</param>
        public static RazorLightEngine CreatePhysical(string root, IEngineConfiguration configuration)
        {
            if (string.IsNullOrEmpty(root))
            {
                throw new ArgumentNullException(nameof(root));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            ITemplateManager templateManager = new FilesystemTemplateManager(root);
            IEngineCore      core            = new EngineCore(templateManager, configuration);

            ICompilerCache       compilerCache = new TrackingCompilerCache(root);
            IPageFactoryProvider pageFactory   = new CachingPageFactory(core.KeyCompile, compilerCache);
            IPageLookup          pageLookup    = new FilesystemPageLookup(pageFactory);

            return(new RazorLightEngine(core, pageLookup));
        }