Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace STDotCom
- {
- using System;
- using System.Web.Mvc;
- /// <summary>
- /// Used to make razor aware of where views are located on a module by module basis.
- /// </summary>
- public class WidgetFolderViewEngine : VirtualPathProviderViewEngine
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="WidgetFolderViewEngine"/> class.
- /// </summary>
- public WidgetFolderViewEngine()
- {
- string[] widgetFolderFormats = new[]
- {
- "~/Widgets/{1}/Views/{0}.cshtml"
- };
- this.FileExtensions = new string[] { "cshtml", "vbhtml", "aspx", "ascx" };
- this.AreaViewLocationFormats = widgetFolderFormats;
- this.AreaMasterLocationFormats = widgetFolderFormats;
- this.AreaPartialViewLocationFormats = widgetFolderFormats;
- this.ViewLocationFormats = widgetFolderFormats;
- this.MasterLocationFormats = widgetFolderFormats;
- this.PartialViewLocationFormats = widgetFolderFormats;
- }
- protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath)
- {
- if (partialPath.EndsWith(".cshtml") || partialPath.EndsWith(".vbhtml"))
- {
- return new RazorView(controllerContext, partialPath, null, false, null);
- }
- else
- {
- return new WebFormView(controllerContext, partialPath);
- }
- }
- protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
- {
- if (viewPath.EndsWith(".cshtml") || viewPath.EndsWith(".vbhtml"))
- {
- return new RazorView(controllerContext, viewPath, masterPath, false, null);
- }
- else
- {
- return new WebFormView(controllerContext, viewPath, masterPath);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement