示例#1
0
        public FeaturesViewEngine()
        {
            ViewLocationCache = new DefaultViewLocationCache();

            var featureFolders = new[]
            {
                "~/Features/%1/{1}/{0}.cshtml",
                "~/Features/%1/%2/{1}/{0}.cshtml",
                "~/Features/%1/{0}.cshtml",
                "~/Features/%1/%2/{0}.cshtml",
                "~/Cms/%1/{1}/{0}.cshtml",
                "~/Commerce/%1/{1}/{0}.cshtml",
                "~/Social/%1/{1}/{0}.cshtml"
            };

            featureFolders = featureFolders.Union(AdditionalPartialViewFormats).ToArray();

            ViewLocationFormats = ViewLocationFormats
                                  .Union(featureFolders)
                                  .ToArray();

            PartialViewLocationFormats = PartialViewLocationFormats
                                         .Union(featureFolders)
                                         .ToArray();

            MasterLocationFormats = MasterLocationFormats
                                    .Union(featureFolders)
                                    .ToArray();
        }
        public ConfiguracionGeneralConfig()
        {
            var viewFormat = ViewLocationFormats.ToList();

            viewFormat.Add("~/Views/Shared/ConfiguracionGeneral/{0}.cshtml");
            ViewLocationFormats = viewFormat.ToArray();
        }
示例#3
0
    /*==========================================================================================================================
    | CONSTRUCTOR
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Initializes a new instance of <see cref="TopicViewEngine"/>.
    /// </summary>
    /// <remarks>
    ///   When instantiated, the <see cref="TopicViewEngine.TopicViewEngine"/> constructor will initialize location formats with
    ///   extensions intended to support organizing views by <see cref="Topic.ContentType"/>.
    /// </remarks>
    public TopicViewEngine(IViewPageActivator viewPageActivator = null) : base(viewPageActivator) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Define view location
      >-------------------------------------------------------------------------------------------------------------------------
      | Supports the following replacement tokens: {0} Controller, {1} View, {2} Area, and {3} Content Type.
      \-----------------------------------------------------------------------------------------------------------------------*/
      var viewLocations = new[] {
        "~/Views/{3}/{1}.cshtml",
        "~/Views/ContentTypes/{3}.{1}.cshtml",
        "~/Views/ContentTypes/{1}.cshtml",
        "~/Views/Shared/{1}.cshtml",
      };

      /*------------------------------------------------------------------------------------------------------------------------
      | Set view locations
      \-----------------------------------------------------------------------------------------------------------------------*/
      ViewLocationFormats = ViewLocationFormats.Union(viewLocations).ToArray();
      MasterLocationFormats = MasterLocationFormats.Union(viewLocations).ToArray();
      PartialViewLocationFormats = PartialViewLocationFormats.Union(viewLocations).ToArray();

      /*------------------------------------------------------------------------------------------------------------------------
      | Update view locations for areas
      \-----------------------------------------------------------------------------------------------------------------------*/
      viewLocations = viewLocations.Select(v => v.Replace("~", "~/{2}/")).ToArray();

      /*------------------------------------------------------------------------------------------------------------------------
      | Set area view locations
      \-----------------------------------------------------------------------------------------------------------------------*/
      AreaViewLocationFormats = AreaViewLocationFormats.Union(viewLocations).ToArray();
      AreaMasterLocationFormats = AreaMasterLocationFormats.Union(viewLocations).ToArray();
      AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Union(viewLocations).ToArray();

    }
        public SiteViewEngine()
        {
            ViewLocationCache = new DefaultViewLocationCache();

            // {0} = action
            // {1} = controller

            var featureFolders = new[]
            {
                "~/Features/Pages/{1}/{1}{0}.cshtml",
                "~/Views/Pages/{1}/{1}{0}.cshtml",     // ~/Views/Pages/Start/StartIndex.cshtml
                "~/Features/{1}{0}.cshtml",
                "~/Features/{1}/{0}.cshtml",
                "~/Features/{1}/Views/{0}.cshtml",
                "~/Features/{1}/Views/{1}.cshtml"
            }
            .Union(SubFeatureFolders("~/Features"))
            .ToArray();

            featureFolders = featureFolders.Union(AdditionalPartialViewFormats).
                             ToArray();

            ViewLocationFormats = ViewLocationFormats
                                  .Union(featureFolders)
                                  .ToArray();

            PartialViewLocationFormats = PartialViewLocationFormats
                                         .Union(featureFolders)
                                         .ToArray();
        }
示例#5
0
        public ModalViewEngine()
        {
            base.PartialViewLocationFormats = base.PartialViewLocationFormats.Union(NewPartialViewFormats).ToArray();
            ViewLocationFormats             = ViewLocationFormats.Union(NewViewFormats).ToArray();


            ///* {0} = view name or master page name
            // * {1} = controller name      */

            //// create our master page location
            //MasterLocationFormats = new[] {
            //    "~/Views/Shared/{0}.master"
            //};

            //// create our views and common shared locations
            //ViewLocationFormats = new[] {
            //    "~/Views/{1}/{0}.aspx",
            //    "~/Views/Admin/{1}/{0}.aspx",
            //    "~/Views/Shared/{0}.aspx",
            //    "~/Views/Admin/Shared/{0}.aspx"
            //};

            //// create our partial views and common shared locations
            //PartialViewLocationFormats = new[] {
            //    "~/Views/{1}/{0}.ascx",
            //    "~/Views/Admin/{1}/{0}.ascx",
            //    "~/Views/Shared/{0}.ascx",
            //    "~/Views/Admin/Shared/{0}.ascx"

            //};
        }
示例#6
0
        public WebStoreViewEngine()
        {
            var newLocationFormat = new[] { "~/Views/BackOffice/{1}/{0}.cshtml" };

            ViewLocationFormats = ViewLocationFormats.Union(newLocationFormat).ToArray();
            //PartialViewLocationFormats = PartialViewLocationFormats.Union (newLocationFormat).ToArray ();
        }
示例#7
0
        public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
        {
            string controllerName = controllerContext.RouteData.GetRequiredString("controller");
            object area;
            string viewArea = null;

            if (controllerContext.RouteData.DataTokens.TryGetValue("area", out area))
            {
                viewArea = area as string;
            }
            var loc = ViewLocationFormats
                      .Select(x => String.Format(x, viewName, controllerName, viewArea))
                      .FirstOrDefault(s => File.Exists(MockVirtualPathFactory.NormalizePath(s)));
            var masterLoc = MasterLocationFormats
                            .Select(x => String.Format(x, viewName, masterName, viewArea))
                            .FirstOrDefault(s => File.Exists(MockVirtualPathFactory.NormalizePath(s)));

            if (loc == null)
            {
                return(new ViewEngineResult(ViewLocationFormats));
            }
            else
            {
                var view = new MockView(MockVirtualPathFactory.NormalizePath(loc), loc, true, FileExtensions);
                return(new ViewEngineResult(view, this));
            }
        }
示例#8
0
 public EPiServerViewEngine()
 {
     this.PartialViewLocationFormats     = PartialViewLocationFormats.Union(ViewFormats).ToArray();
     this.ViewLocationFormats            = ViewLocationFormats.Union(ViewFormats).ToArray();
     this.AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Union(AreaViewFormats).ToArray();
     this.AreaViewLocationFormats        = AreaViewLocationFormats.Union(AreaViewFormats).ToArray();
     this.AreaMasterLocationFormats      = AreaMasterViewFormats.Union(AreaMasterViewFormats).ToArray();
     this.MasterLocationFormats          = MasterLocationFormats.Union(MasterViewFormats).ToArray();
 }
        private void Initialize()
        {
            MasterLocationFormats      = MasterLocationFormats.CSharpHtmlOnly();
            ViewLocationFormats        = ViewLocationFormats.CSharpHtmlOnly();
            PartialViewLocationFormats = PartialViewLocationFormats.CSharpHtmlOnly();

            AreaMasterLocationFormats      = AreaMasterLocationFormats.CSharpHtmlOnly();
            AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.CSharpHtmlOnly();
            AreaViewLocationFormats        = AreaViewLocationFormats.CSharpHtmlOnly();
        }
示例#10
0
 public CsRazorViewEngine(IViewPageActivator viewPageActivator)
     : base(viewPageActivator)
 {
     AreaViewLocationFormats        = AreaViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     AreaMasterLocationFormats      = AreaMasterLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     ViewLocationFormats            = ViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     MasterLocationFormats          = MasterLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     PartialViewLocationFormats     = PartialViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     FileExtensions = FileExtensions.Where(f => f.EndsWith("cshtml")).ToArray();
 }
示例#11
0
        private void OverrideTemplatePaths()
        {
            List <string> paths = ViewLocationFormats.ToList();

            paths.Insert(0, "~/{0}");
            ViewLocationFormats = paths.ToArray();

            paths = PartialViewLocationFormats.ToList();
            paths.Insert(0, "~/{0}");
            PartialViewLocationFormats = paths.ToArray();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Employment.Web.Mvc.Infrastructure.ViewEngines.CsRazorViewEngine" /> class.
        /// </summary>
        public CsRazorViewEngine()
        {
            const string extension = "cshtml";

            // Only include the cshtml type in location formats and file extensions
            AreaViewLocationFormats        = AreaViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            AreaMasterLocationFormats      = AreaMasterLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            ViewLocationFormats            = ViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            MasterLocationFormats          = MasterLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            PartialViewLocationFormats     = PartialViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            FileExtensions = FileExtensions.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
        }
    public ExpandedViewEngine()
    {
        var thirdPartySubfolders = new[]
        {
            "~/Areas/B2b/Views/Shopify/{1}/{0}.cshtml"
        };

        ViewLocationFormats = ViewLocationFormats.Union(thirdPartySubfolders).ToArray();
        // use the following if you want to extend the partial locations
        // PartialViewLocationFormats = PartialViewLocationFormats.Union(new[] { "new partial location" }).ToArray();
        // use the following if you want to extend the master locations
        // MasterLocationFormats = MasterLocationFormats.Union(new[] { "new master location" }).ToArray();
    }
示例#14
0
        public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
        {
            string        action     = controllerContext.RouteData.Values["action"].ToString();
            string        controller = controllerContext.RouteData.Values["controller"].ToString();
            List <string> list       = ViewLocationFormats.ToList();

            if (controller == "MainServlet")
            {
                list.Add("~/Views/" + controller + "/{0}.cshtml");
            }
            ViewLocationFormats = list.ToArray();
            return(base.FindView(controllerContext, viewName, masterName, useCache));
        }
示例#15
0
        public L24ViewEngine()
        {
            var addLocations = new[]
            {
                "~/Areas/L24CM/Views/Shared/{0}.aspx",
                "~/Areas/L24CM/Views/Shared/{0}.ascx"
            };

            ViewLocationFormats        = ViewLocationFormats.Concat(addLocations).ToArray();
            PartialViewLocationFormats = PartialViewLocationFormats.Concat(addLocations).ToArray();

            AreaViewLocationFormats        = AreaViewLocationFormats.Concat(addLocations).ToArray();
            AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Concat(addLocations).ToArray();
        }
        public MyCustomViewEngine()
        {
            List <string> existingViewLocationFormats = ViewLocationFormats.ToList();

            //Folder Structure: Views\Home\Desktop and Views\Home\Mobile
            existingViewLocationFormats.Insert(0, "~/Views/{1}/Desktop/{0}.cshtml");
            existingViewLocationFormats.Insert(0, "~/Views/{1}/Mobile/{0}.cshtml");

            //Folder Structure: Views\Desktop\Home and Views\Mobile\Home
            existingViewLocationFormats.Insert(0, "~/Views/Desktop/{1}/{0}.cshtml");
            existingViewLocationFormats.Insert(0, "~/Views/Mobile/{1}/{0}.cshtml");

            ViewLocationFormats = existingViewLocationFormats.ToArray();
        }
示例#17
0
        public void setupViewLocations(List <string> viewLocations)
        {
            string[] tempArray = new string[ViewLocationFormats.Length + viewLocations.Count];
            ViewLocationFormats.CopyTo(tempArray, 0);

            for (int i = 0; i < viewLocations.Count; i++)
            {
                tempArray[ViewLocationFormats.Length + i] = viewLocations[i];
            }

            ViewLocationFormats = tempArray;

            PartialViewLocationFormats = ViewLocationFormats;
        }
示例#18
0
        public FeatureViewEngine()
        {
            var featureFolderViewLocationFormats = new[]
            {
                "~/Features/{0}.cshtml",
                "~/Features/{1}/{0}.cshtml",
                "~/Features/{1}/Views/{0}.cshtml"
            }
            .Union(FeatureFolders())
            .ToArray();

            ViewLocationFormats        = ViewLocationFormats.Union(featureFolderViewLocationFormats).ToArray();
            MasterLocationFormats      = MasterLocationFormats.Union(featureFolderViewLocationFormats).ToArray();
            PartialViewLocationFormats = PartialViewLocationFormats.Union(featureFolderViewLocationFormats).ToArray();
        }
示例#19
0
        /// <summary>
        /// 插件视图构造函数,将视图位置,添加到默认查找中
        /// </summary>
        /// <param name="viewLocations"></param>
        public PluginViewEngine(string[] viewLocations)
            : base()
        {
            string[] tempArray = new string[ViewLocationFormats.Length + viewLocations.Length];
            ViewLocationFormats.CopyTo(tempArray, 0);

            for (int i = 0; i < viewLocations.Length; i++)
            {
                tempArray[ViewLocationFormats.Length + i] = viewLocations[i];
            }

            ViewLocationFormats = tempArray;

            PartialViewLocationFormats = ViewLocationFormats;
        }
示例#20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JetViewEngine" /> class.
        /// </summary>
        public JetViewEngine()
        {
            ViewLocationFormats =
                ViewLocationFormats.Concat(new[]
            {
                "~/Views/{1}/{0}.cshtml",
                "~/Views/Shared/{0}.cshtml"
            }).Distinct().ToArray();

            PartialViewLocationFormats =
                PartialViewLocationFormats.Concat(new[]
            {
                "~/Views/{1}/{0}.cshtml",
                "~/Views/Shared/{0}.cshtml"
            }).Distinct().ToArray();
        }
示例#21
0
        public MultiDeviceRazorViewEngine()
        {
            var newViewLocations = new[]
            {
                "~/Views/{1}/{0}/{0}.cshtml",
                "~/Views/{1}/{0}/Partials/{0}.cshtml",
                "~/Views/{1}/Partials/{0}.cshtml",
                "~/Views/{1}/Partials/{0}/{0}.cshtml",
                "~/Views/Shared/{0}/{0}.cshtml",
                "~/Views/Shared/Partials/{0}.cshtml",
                "~/Views/Shared/Partials/{0}/{0}.cshtml"
            };

            ViewLocationFormats        = ViewLocationFormats.Union(newViewLocations).ToArray();
            MasterLocationFormats      = MasterLocationFormats.Union(newViewLocations).ToArray();
            PartialViewLocationFormats = PartialViewLocationFormats.Union(newViewLocations).ToArray();
        }
示例#22
0
        public MyWebFormViewEngine()
            : base()
        {
            MasterLocationFormats = new[] {
                "~/Views/%1/{1}/{0}.master",
                "~/Views/%1/Shared/{0}.master"
            };

            AreaMasterLocationFormats = new[] {
                "~/Areas/{2}/Views/%1/{1}/{0}.master",
                "~/Areas/{2}/Views/%1/Shared/{0}.master",
            };

            ViewLocationFormats = new[] {
                "~/Views/%1/{1}/{0}.aspx",
                "~/Views/%1/{1}/{0}.ascx",
                "~/Views/%1/Shared/{0}.aspx",
                "~/Views/%1/Shared/{0}.ascx"
            };

            AreaViewLocationFormats = new[] {
                "~/Areas/{2}/Views/%1/{1}/{0}.aspx",
                "~/Areas/{2}/Views/%1/{1}/{0}.ascx",
                "~/Areas/{2}/Views/%1/Shared/{0}.aspx",
                "~/Areas/{2}/Views/%1/Shared/{0}.ascx",
            };

            PartialViewLocationFormats     = ViewLocationFormats;
            AreaPartialViewLocationFormats = AreaViewLocationFormats;

            var addLocations = new[]
            {
                "~/Views/%1/{0}.aspx",
                "~/Views/%1/{0}.ascx"
            };


            ViewLocationFormats        = ViewLocationFormats.Concat(addLocations).ToArray();
            PartialViewLocationFormats = PartialViewLocationFormats.Concat(addLocations).ToArray();

            AreaViewLocationFormats        = AreaViewLocationFormats.Concat(addLocations).ToArray();
            AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Concat(addLocations).ToArray();
        }
示例#23
0
        public void AddViewLocationFormats()
        {
            var additionalViewLocationFormats = new List <string>()
            {
                "~/Plugins/Payments.GBS/Views/{0}.cshtml",
                "~/Plugins/Payments.GBS/Views/{1}/{0}.cshtml"
            };

            var currentViewLocationFormats = ViewLocationFormats.ToList();

            currentViewLocationFormats.InsertRange(0, additionalViewLocationFormats);

            ViewLocationFormats = currentViewLocationFormats.ToArray();

            var currentPartialViewLocationFormats = PartialViewLocationFormats.ToList();

            currentPartialViewLocationFormats.InsertRange(0, additionalViewLocationFormats);

            PartialViewLocationFormats = currentPartialViewLocationFormats.ToArray();
        }
示例#24
0
        /// <summary>
        ///  Constructor for the custom view engine.
        /// </summary>
        public ViewEngineConfig() : base()
        {
            List <string> masterLocationFormats      = MasterLocationFormats.ToList();
            List <string> partialViewLocationFormats = PartialViewLocationFormats.ToList();
            List <string> viewLocationFormats        = ViewLocationFormats.ToList();

            List <string> featureLocationFormats = new List <string>
            {
                "~/Features/{1}/Views/{0}.cshtml",
                "~/Features/{1}/Views/Shared/{0}.cshtml",
            };

            masterLocationFormats.AddRange(featureLocationFormats);
            partialViewLocationFormats.AddRange(featureLocationFormats);
            viewLocationFormats.AddRange(featureLocationFormats);

            this.MasterLocationFormats      = masterLocationFormats.ToArray();
            this.PartialViewLocationFormats = partialViewLocationFormats.ToArray();
            this.ViewLocationFormats        = viewLocationFormats.ToArray();
        }
示例#25
0
        /*
         * Placeholders:
         *      {2} - Name of the Mvc area
         *      {1} - Name of the controller
         *      {0} - Name of the action (name of the partial view)
         */

        public SiteViewEngine()
        {
            var featureFolders = new[]
            {
                "~/Features/{0}.cshtml",
                "~/Features/{1}{0}.cshtml",
                "~/Features/{1}/{0}.cshtml",
                "~/Features/{1}/Views/{0}.cshtml",
                "~/Features/{1}/Views/{1}.cshtml",
            }
            .Union(SubFeatureFolders("~/Features"))
            .ToArray();

            ViewLocationFormats = ViewLocationFormats
                                  .Union(featureFolders)
                                  .ToArray();

            PartialViewLocationFormats = PartialViewLocationFormats
                                         .Union(featureFolders)
                                         .ToArray();
        }
        public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName,
                                                  string masterName, bool useCache)
        {
            viewName = viewName.ToTitleCaseString();

            if (controllerContext == null)
            {
                throw new ArgumentNullException(nameof(controllerContext), "The controllerContext parameter is null");
            }

            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentException("The viewName parameter is null or empty.", nameof(viewName));
            }

            if (controllerContext.Controller == null)
            {
                return(base.FindView(controllerContext, viewName, masterName, useCache));
            }

            var pluginName = controllerContext.Controller.ToControllerShortName();

            if (string.IsNullOrEmpty(pluginName))
            {
                return(base.FindView(controllerContext, viewName, masterName, useCache));
            }
            var cacheKey = $"{pluginName}|{viewName}";

            if (useCache && ViewLocationCache != null)
            {
                var cachedLocation = ViewLocationCache.GetViewLocation(controllerContext.HttpContext, cacheKey);
                if (!string.IsNullOrEmpty(cachedLocation))
                {
                    return(new ViewEngineResult(CreateView(controllerContext, cachedLocation, masterName),
                                                this));
                }
            }

            string trimmedViewName;

            if (viewName.EndsWith(".cshtml") || viewName.EndsWith(".vbhtml"))
            {
                trimmedViewName = viewName.Remove(viewName.Length - 7);
            }
            else
            {
                trimmedViewName = viewName;
            }
            var args = new object[] { trimmedViewName, pluginName };

            foreach (var location in ViewLocationFormats)
            {
                var path = string.Format(location, args);

                if (!FileExists(controllerContext, path))
                {
                    continue;
                }

                ViewLocationCache?.InsertViewLocation(controllerContext.HttpContext, cacheKey, path);

                return(new ViewEngineResult(CreateView(controllerContext, path, masterName), this));
            }
            return(new ViewEngineResult(ViewLocationFormats.Select(i => string.Format(i, args))));
        }
示例#27
0
 public SiteViewEngine()
 {
     PartialViewLocationFormats =
         PartialViewLocationFormats.Union(AdditionalPartialViewFormats).ToArray();
     ViewLocationFormats = ViewLocationFormats.Union(AdditionViewLocationFormats).ToArray();
 }
 public CustomLocationViewEngine()
 {
     ViewLocationFormats        = ViewLocationFormats.Union(Locations).ToArray();
     PartialViewLocationFormats = PartialViewLocationFormats.Union(Locations).ToArray();
 }