Example #1
0
 public OverloadedLocationViewEngine(IRazorPageFactory pageFactory,
                                     IRazorViewFactory viewFactory,
                                     IViewLocationExpanderProvider expanderProvider,
                                     IViewLocationCache cache)
     : base(pageFactory, viewFactory, expanderProvider, cache)
 {
 }
Example #2
0
 public OverloadedLocationViewEngine(IRazorPageFactory pageFactory,
                                     IRazorViewFactory viewFactory,
                                     IOptions <RazorViewEngineOptions> optionsAccessor,
                                     IViewLocationCache cache)
     : base(pageFactory, viewFactory, optionsAccessor, cache)
 {
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MinifiedRazorViewEngine" /> class.
 /// </summary>
 /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param>
 public MinifiedRazorViewEngine(
     IRazorPageFactory pageFactory,
     IRazorViewFactory viewFactory,
     IOptions <RazorViewEngineOptions> optionsAccessor,
     IViewLocationCache viewLocationCache)
     : base(pageFactory, viewFactory, optionsAccessor, viewLocationCache)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MinifiedRazorViewEngine" /> class.
 /// </summary>
 /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param>
 public MinifiedRazorViewEngine(
     IRazorPageFactory pageFactory,
     IRazorViewFactory viewFactory,
     IOptions<RazorViewEngineOptions> optionsAccessor,
     IViewLocationCache viewLocationCache)
     : base(pageFactory, viewFactory, optionsAccessor, viewLocationCache)
 {
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RazorViewEngine" /> class.
 /// </summary>
 /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param>
 public RazorViewEngine(IRazorPageFactory pageFactory,
                        IViewLocationExpanderProvider viewLocationExpanderProvider,
                        IViewLocationCache viewLocationCache)
 {
     _pageFactory           = pageFactory;
     _viewLocationExpanders = viewLocationExpanderProvider.ViewLocationExpanders;
     _viewLocationCache     = viewLocationCache;
 }
Example #6
0
        public void ViewLocationCache_RoundTrips()
        {
            // Arrange & Act
            IViewLocationCache locationCache = _engine.ViewLocationCache;

            // Assert
            Assert.NotNull(locationCache);
            Assert.Equal(_engine.MockCache.Object, _engine.ViewLocationCache);
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RazorViewEngine" /> class.
 /// </summary>
 /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param>
 public RazorViewEngine(IRazorPageFactory pageFactory,
                        IRazorViewFactory viewFactory,
                        IOptions <RazorViewEngineOptions> optionsAccessor,
                        IViewLocationCache viewLocationCache)
 {
     _pageFactory           = pageFactory;
     _viewFactory           = viewFactory;
     _viewLocationExpanders = optionsAccessor.Options.ViewLocationExpanders;
     _viewLocationCache     = viewLocationCache;
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RazorViewEngine" /> class.
 /// </summary>
 /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param>
 public RazorViewEngine(IRazorPageFactory pageFactory,
                        IRazorViewFactory viewFactory,
                        IOptions<RazorViewEngineOptions> optionsAccessor,
                        IViewLocationCache viewLocationCache)
 {
     _pageFactory = pageFactory;
     _viewFactory = viewFactory;
     _viewLocationExpanders = optionsAccessor.Options.ViewLocationExpanders;
     _viewLocationCache = viewLocationCache;
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RazorViewEngine" /> class.
 /// </summary>
 /// <param name="pageFactory">The page factory used for creating <see cref="IRazorPage"/> instances.</param>
 public RazorViewEngine(IRazorPageFactory pageFactory,
                        IRazorViewFactory viewFactory,
                        IViewLocationExpanderProvider viewLocationExpanderProvider,
                        IViewLocationCache viewLocationCache)
 {
     _pageFactory = pageFactory;
     _viewFactory = viewFactory;
     _viewLocationExpanders = viewLocationExpanderProvider.ViewLocationExpanders;
     _viewLocationCache = viewLocationCache;
 }
Example #10
0
        public WaCoreRazorViewEngine(
            IRazorPageFactory pageFactory,
            IRazorViewFactory viewFactory,
            IOptions <RazorViewEngineOptions> optionsAccessor,
            IViewLocationCache viewLocationCache) : base(pageFactory, viewFactory, optionsAccessor, viewLocationCache)
        {
            //https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs

            // {0} represents the name of the view
            // {1} represents the name of the controller
            // {2} represents the name of the area
        }
        public static Response RenderView(this IViewFactory factory, IViewLocationCache cache, NancyContext context, string viewName, object model = null)
        {
            var foundMatchingView = cache.Any(x => viewName.Equals(string.Concat(x.Location, "/", x.Name, ".", x.Extension), StringComparison.OrdinalIgnoreCase));

            if (foundMatchingView)
            {
                var viewContext = new ViewLocationContext { Context = context };
                context.Response = factory.RenderView(viewName, model, viewContext);
            }

            return context.Response;
        }
		protected PluginViewEngine(PluginContext pluginContext)
		{
			if(pluginContext == null)
				throw new ArgumentNullException("pluginContext");

			_pluginContext = pluginContext;

			if(HttpContext.Current == null || HttpContext.Current.IsDebuggingEnabled)
				_viewLocationCache = DefaultViewLocationCache.Null;
			else
				_viewLocationCache = new DefaultViewLocationCache();
		}
        public TwoLevelViewLocationCache()
        {
            var cacheDuringDebug = CommonHelper.GetAppSetting <bool>("sm:EnableViewLocationCacheDuringDebug");

            if (!cacheDuringDebug && (HttpContext.Current == null || HttpContext.Current.IsDebuggingEnabled))
            {
                _innerCache = DefaultViewLocationCache.Null;
            }
            else
            {
                _innerCache = new DefaultViewLocationCache(TimeSpan.FromHours(2));
            }
        }
Example #14
0
        public void ViewLocationCache_DefaultNullCache()
        {
            // Arrange
            Mock <VirtualPathProviderViewEngine> engineMock = new Mock <VirtualPathProviderViewEngine>();
            VirtualPathProviderViewEngine        engine     = engineMock.Object;

            // Act
            IViewLocationCache cache = engine.ViewLocationCache;

            // Assert
            Assert.NotNull(cache);
            Assert.Equal(DefaultViewLocationCache.Null, cache);
            Assert.IsNotType <DefaultViewLocationCache>(cache);
        }
Example #15
0
        //IRazorViewEngine
        public CoreViewEngine(
            IRazorPageFactory pageFactory, 
            IRazorViewFactory viewFactory,
            IOptions<RazorViewEngineOptions> optionsAccessor,
            IViewLocationCache viewLocationCache):base(pageFactory, viewFactory, optionsAccessor, viewLocationCache)
        {
            //https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs

            // {0} represents the name of the view
            // {1} represents the name of the controller
            // {2} represents the name of the area
            

        }
Example #16
0
        private IViewEngine CreateViewEngine(IRazorPageFactory pageFactory = null,
                                             IEnumerable <IViewLocationExpander> expanders = null,
                                             IViewLocationCache cache = null)
        {
            pageFactory = pageFactory ?? Mock.Of <IRazorPageFactory>();
            cache       = cache ?? GetViewLocationCache();
            var viewLocationExpanderProvider = GetViewLocationExpanders(expanders);

            var viewEngine = new RazorViewEngine(pageFactory,
                                                 viewLocationExpanderProvider,
                                                 cache);

            return(viewEngine);
        }
Example #17
0
        private RazorViewEngine CreateViewEngine(IRazorPageFactory pageFactory = null,
                                                 IRazorViewFactory viewFactory = null,
                                                 IEnumerable <IViewLocationExpander> expanders = null,
                                                 IViewLocationCache cache = null)
        {
            pageFactory = pageFactory ?? Mock.Of <IRazorPageFactory>();
            viewFactory = viewFactory ?? Mock.Of <IRazorViewFactory>();

            cache = cache ?? GetViewLocationCache();

            var viewEngine = new RazorViewEngine(pageFactory,
                                                 viewFactory,
                                                 GetOptionsAccessor(expanders),
                                                 cache);

            return(viewEngine);
        }
Example #18
0
        protected PluginViewEngine(PluginContext pluginContext)
        {
            if (pluginContext == null)
            {
                throw new ArgumentNullException("pluginContext");
            }

            _pluginContext = pluginContext;

            if (HttpContext.Current == null || HttpContext.Current.IsDebuggingEnabled)
            {
                _viewLocationCache = DefaultViewLocationCache.Null;
            }
            else
            {
                _viewLocationCache = new DefaultViewLocationCache();
            }
        }
        /// <summary>实例化</summary>
        /// <param name="assemblyName"></param>
        /// <param name="innerCache"></param>
		public PrecompiledViewLocationCache(String assemblyName, IViewLocationCache innerCache)
		{
			_assemblyName = assemblyName;
			_innerCache = innerCache;
		}
Example #20
0
 public TwoLevelViewCache(IViewLocationCache cache)
 {
     _cache = cache;
 }
Example #21
0
 public ViewEngineStartupFixture()
 {
     this.viewCache = A.Fake<IViewCache>();
     this.viewLocationCache = A.Fake<IViewLocationCache>();
     A.CallTo(() => this.viewLocationCache.GetEnumerator()).ReturnsLazily(() => this.views.GetEnumerator());
 }
Example #22
0
 public TwoLevelViewCache(IViewLocationCache secondLevelCache)
 {
     _secondLevelCache = secondLevelCache;
 }
 private static DefaultViewLocator CreateViewLocator(IViewLocationCache viewLocationCache)
 {
     return new DefaultViewLocator(viewLocationCache);
 }
 public ViewLocationCached(IViewLocationCache cache)
 {
     _cache = cache;
 }
 public DefaultViewEngine(IRazorPageFactory pageFactory, IRazorViewFactory viewFactory, IViewLocationExpanderProvider viewLocationExpanderProvider, IViewLocationCache viewLocationCache)
     : base(pageFactory, viewFactory, viewLocationExpanderProvider, viewLocationCache)
 {
 }
Example #26
0
 private static DefaultViewLocator CreateViewLocator(IViewLocationCache viewLocationCache)
 {
     return(new DefaultViewLocator(viewLocationCache));
 }
Example #27
0
 public DefaultViewLocator(IViewLocationCache viewLocationCache)
 {
     this.viewLocationCache = viewLocationCache;
 }
 public PrecompiledViewLocationCache(IViewLocationCache innerCache)
 {
     _prexif = "precompiled";
     _innerCache = innerCache;
 }
Example #29
0
 public DefaultViewLocator(IViewLocationCache viewLocationCache)
 {
     this.viewLocationCache = viewLocationCache;
 }
 public OverloadedLocationViewEngine(IRazorPageFactory pageFactory,
                                     IRazorViewFactory viewFactory,
                                     IViewLocationExpanderProvider expanderProvider,
                                     IViewLocationCache cache)
     : base(pageFactory, viewFactory, expanderProvider, cache)
 {
 }
Example #31
0
        private RazorViewEngine CreateViewEngine(
            IRazorPageFactory pageFactory = null,
            IRazorViewFactory viewFactory = null,
            IEnumerable<IViewLocationExpander> expanders = null,
            IViewLocationCache cache = null)
        {
            pageFactory = pageFactory ?? Mock.Of<IRazorPageFactory>();
            viewFactory = viewFactory ?? Mock.Of<IRazorViewFactory>();

            cache = cache ?? GetViewLocationCache();

            var viewEngine = new RazorViewEngine(pageFactory,
                                                 viewFactory,
                                                 GetOptionsAccessor(expanders),
                                                 cache);

            return viewEngine;
        }
 public PortalViewEngine(IControllerFileService controllerFileService, IViewLocationCache viewLocationCache)
 {
     this.controllerFileService = controllerFileService;
     this.viewLocationCache = viewLocationCache;
 }
Example #33
0
 public PrecompiledViewLocationCache(string assemblyName, IViewLocationCache innerCache)
 {
     _assemblyName = assemblyName;
     _innerCache   = innerCache;
 }
Example #34
0
 public DefaultViewLocatorFixture()
 {
     this.viewLocation      = new ViewLocationResult("location", "view", "html", null);
     this.viewLocationCache = new FakeViewLocationCache(this.viewLocation);
     this.viewLocator       = CreateViewLocator(this.viewLocationCache);
 }
Example #35
0
 public ViewEngineStartup(IEnumerable<IViewEngine> viewEngines, IViewLocationCache viewLocationCache, IViewCache viewCache)
 {
     this.viewEngines = viewEngines;
     this.viewLocationCache = viewLocationCache;
     this.viewCache = viewCache;
 }
Example #36
0
 public TwoLevelViewCache(IViewLocationCache cache)
 {
     _cache = cache;
 }
Example #37
0
 public ViewLocationCache(IViewLocationCache locache)
 {
     cache = locache;
 }
 public Generic404ErrorHandler(IViewFactory factory, IViewLocationCache cache)
 {
     _factory = factory;
     _cache = cache;
 }
 public DefaultViewLocatorFixture()
 {
     this.viewLocation = new ViewLocationResult("location", "view", "html", null);
     this.viewLocationCache = new FakeViewLocationCache(this.viewLocation);
     this.viewLocator = CreateViewLocator(this.viewLocationCache);
 }
Example #40
0
 public ViewEngineStartup(IEnumerable <IViewEngine> viewEngines, IViewLocationCache viewLocationCache, IViewCache viewCache)
 {
     this.viewEngines       = viewEngines;
     this.viewLocationCache = viewLocationCache;
     this.viewCache         = viewCache;
 }
 public ViewEngineStartupFixture()
 {
     this.viewCache         = A.Fake <IViewCache>();
     this.viewLocationCache = A.Fake <IViewLocationCache>();
     A.CallTo(() => this.viewLocationCache.GetEnumerator()).ReturnsLazily(() => this.views.GetEnumerator());
 }
Example #42
0
 public OverloadedLocationViewEngine(
     IRazorPageFactory pageFactory,
     IRazorViewFactory viewFactory,
     IOptions<RazorViewEngineOptions> optionsAccessor,
     IViewLocationCache cache)
     : base(pageFactory, viewFactory, optionsAccessor, cache)
 {
 }
        public TwoLevelViewCache(IViewLocationCache cache) {
            _cache = cache;
        }