1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc.Razor;
- namespace MySystem
- {
- public class TemplateViewLocationExpander : IViewLocationExpander
- {
- public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
- {
- /// <summary>
- /// view文件路径
- /// </summary>
- /// <value></value>
- string[] locations = {
- "/Areas/Admin/Views/BsServer/{1}/{0}.cshtml",
- "/Areas/Admin/Views/MainServer/{1}/{0}.cshtml",
- "/Areas/Admin/Views/JobServer/{1}/{0}.cshtml",
- "/Areas/Admin/Views/CashServer/{1}/{0}.cshtml",
- "/Areas/Admin/Views/SpServer/{1}/{0}.cshtml",
- "/Areas/Admin/Views/OperateServer/{1}/{0}.cshtml",
- };
- return locations.Union(viewLocations);
- }
- public void PopulateValues(ViewLocationExpanderContext context)
- {
- context.Values["template"] = context.ActionContext.RouteData.Values["Template"]?.ToString() ?? "Default";
- }
- }
- }
|