Skip to content

Commit 65808c0

Browse files
Closes #11
1 parent 2b15118 commit 65808c0

File tree

6 files changed

+170
-2
lines changed

6 files changed

+170
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Reflection;
4+
using System.Web.Mvc;
5+
using DeveloperTools.Models;
6+
using EPiServer.Shell.Web.Mvc;
7+
8+
namespace DeveloperTools.Controllers
9+
{
10+
public class ViewEngineLocationsController : DeveloperToolsController
11+
{
12+
public ActionResult Index()
13+
{
14+
var model = new ViewEngineLocationsModel();
15+
16+
foreach (var engine in ViewEngines.Engines.OfType<VirtualPathProviderViewEngine>())
17+
{
18+
var engineName = engine.GetType().Name;
19+
model.ViewLocations.AddRange(engine.ViewLocationFormats.Select(f => new ViewEngineLocationItemModel(f, engineName)));
20+
model.PartialViewLocations.AddRange(engine.PartialViewLocationFormats.Select(f => new ViewEngineLocationItemModel(f, engineName)));
21+
}
22+
23+
// special treatment for module view engine collection
24+
var modules = ViewEngines.Engines.OfType<ModuleViewEngineCollection>().FirstOrDefault();
25+
var memberInfo = modules?.GetType().GetField("_viewEngines", BindingFlags.NonPublic | BindingFlags.Instance);
26+
27+
if(memberInfo != null)
28+
{
29+
var enginesCollection = memberInfo?.GetValue(modules) as Dictionary<string, IViewEngine>;
30+
if(enginesCollection != null)
31+
{
32+
foreach (var engine in enginesCollection.Values.OfType<WebFormViewEngine>())
33+
{
34+
var engineName = engine.GetType().Name;
35+
model.ViewLocations.AddRange(engine.ViewLocationFormats.Select(f => new ViewEngineLocationItemModel(f, engineName)));
36+
model.PartialViewLocations.AddRange(engine.PartialViewLocationFormats.Select(f => new ViewEngineLocationItemModel(f, engineName)));
37+
}
38+
}
39+
}
40+
41+
return View(model);
42+
}
43+
}
44+
}

DeveloperTools/Core/DeveloperMenuProvider.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public class DeveloperMenuProvider : IMenuProvider
4343
const string RoutesTitle = "Routes";
4444
const string RoutesPath = "global/DeveloperTools/Routes";
4545

46+
const string ViewLocationsTitle = "View Locations";
47+
const string ViewLocationsPath = "global/DeveloperTools/ViewLocations";
48+
4649
public IEnumerable<MenuItem> GetMenuItems()
4750
{
4851
// Create the top menu section
@@ -61,9 +64,23 @@ public IEnumerable<MenuItem> GetMenuItems()
6164
var memoryDumperViewer = CreateUrlMenuItem(MemoryDumpTitle, MemoryDumpPath, Paths.ToResource(ModuleName, "MemoryDump"));
6265
var remoteEventViewer = CreateUrlMenuItem(RemoteEventTitle, RemoteEventPath, Paths.ToResource(ModuleName, "RemoteEvent"));
6366
var routes = CreateUrlMenuItem(RoutesTitle, RoutesPath, Paths.ToResource(ModuleName, "Routes"));
67+
var viewLocations = CreateUrlMenuItem(ViewLocationsTitle, ViewLocationsPath, Paths.ToResource(ModuleName, "ViewEngineLocations"));
6468

6569
return new MenuItem[]
66-
{ developerSection, timeMeters, ioc, loadedAssemblies, revertToDefault, contentTypeAnalyzer, templates, logViewer, memoryDumperViewer, remoteEventViewer, routes };
70+
{
71+
developerSection,
72+
timeMeters,
73+
ioc,
74+
loadedAssemblies,
75+
revertToDefault,
76+
contentTypeAnalyzer,
77+
templates,
78+
logViewer,
79+
memoryDumperViewer,
80+
remoteEventViewer,
81+
routes,
82+
viewLocations
83+
};
6784
}
6885

6986
protected virtual UrlMenuItem CreateUrlMenuItem(string title, string logicalPath, string resourcePath)

DeveloperTools/DeveloperTools.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
<Compile Include="Controllers\IOCController.cs" />
204204
<Compile Include="Controllers\TemplatesController.cs" />
205205
<Compile Include="Controllers\TimeMetersController.cs" />
206+
<Compile Include="Controllers\ViewEngineLocationsController.cs" />
206207
<Compile Include="Core\DeveloperMenuProvider.cs" />
207208
<Compile Include="Models\AssembliesModel.cs" />
208209
<Compile Include="Models\RouteModel.cs" />
@@ -211,6 +212,7 @@
211212
<Compile Include="Models\IOCModel.cs" />
212213
<Compile Include="Models\LoggerSettings.cs" />
213214
<Compile Include="Models\LogSettingsAndEvents.cs" />
215+
<Compile Include="Models\ViewEngineLocationsModel.cs" />
214216
<Compile Include="Properties\AssemblyInfo.cs" />
215217
<Compile Include="Core\RollingMemoryAppender.cs" />
216218
</ItemGroup>
@@ -232,8 +234,13 @@
232234
</None>
233235
<None Include="modules\_protected\EPiServer.DeveloperTools\Views\MemoryDump\Index.aspx" />
234236
<None Include="modules\_protected\EPiServer.DeveloperTools\Views\RevertToDefault\Index.aspx" />
235-
<None Include="modules\_protected\EPiServer.DeveloperTools\Views\Templates\Index.aspx" />
237+
<None Include="modules\_protected\EPiServer.DeveloperTools\Views\Templates\Index.aspx">
238+
<SubType>ASPXCodeBehind</SubType>
239+
</None>
236240
<None Include="modules\_protected\EPiServer.DeveloperTools\Views\TimeMeters\Index.aspx" />
241+
<None Include="modules\_protected\EPiServer.DeveloperTools\Views\ViewEngineLocations\Index.aspx">
242+
<SubType>ASPXCodeBehind</SubType>
243+
</None>
237244
<Content Include="modules\_protected\EPiServer.DeveloperTools\Web.config" />
238245
</ItemGroup>
239246
<ItemGroup />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Collections.Generic;
2+
3+
namespace DeveloperTools.Models
4+
{
5+
public class ViewEngineLocationsModel
6+
{
7+
public ViewEngineLocationsModel()
8+
{
9+
ViewLocations = new List<ViewEngineLocationItemModel>();
10+
PartialViewLocations = new List<ViewEngineLocationItemModel>();
11+
}
12+
13+
public List<ViewEngineLocationItemModel> ViewLocations { get; private set; }
14+
public List<ViewEngineLocationItemModel> PartialViewLocations { get; private set; }
15+
}
16+
17+
public class ViewEngineLocationItemModel
18+
{
19+
public ViewEngineLocationItemModel(string location, string engineName)
20+
{
21+
Location = location;
22+
EngineName = engineName;
23+
}
24+
25+
public string EngineName { get; private set; }
26+
27+
public string Location { get; private set; }
28+
}
29+
}
Binary file not shown.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<DeveloperTools.Models.ViewEngineLocationsModel>" MasterPageFile="../Shared/DeveloperTools.Master" %>
2+
<%@ Import Namespace="EPiServer.DataAbstraction" %>
3+
4+
<asp:Content ID="Content" runat="server" ContentPlaceHolderID="MainRegion">
5+
6+
<link rel="stylesheet" type="text/css" href="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css" />
7+
<script type="text/javascript" language="javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
8+
<script src="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js" type="text/javascript"></script>
9+
<h1>View Engine Locations</h1>
10+
<p>Show a list of all view locations where Mvc would look for templates.</p>
11+
12+
<table cellpadding="0" cellspacing="0" border="0" class="display" id="theViewLocations">
13+
<thead>
14+
<tr>
15+
<th align="left">View Location</th>
16+
<th align="left">Engine</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<% foreach (var l in Model.ViewLocations){%>
21+
<tr>
22+
<td><%:l.Location%></td>
23+
<td><%:l.EngineName%></td>
24+
</tr>
25+
<%}%>
26+
</tbody>
27+
</table>
28+
29+
<table cellpadding="0" cellspacing="0" border="0" class="display" id="thePartialViewLocations">
30+
<thead>
31+
<tr>
32+
<th align="left">Partial View Location</th>
33+
<th align="left">Engine</th>
34+
</tr>
35+
</thead>
36+
<tbody>
37+
<% foreach (var l in Model.PartialViewLocations){%>
38+
<tr>
39+
<td><%:l.Location%></td>
40+
<td><%:l.EngineName%></td>
41+
</tr>
42+
<%}%>
43+
</tbody>
44+
</table>
45+
46+
<script>
47+
$(document).ready(function () {
48+
$('#theViewLocations').dataTable(
49+
{
50+
"aaSorting": [[0, "desc"]],
51+
"bPaginate": false,
52+
"bLengthChange": false,
53+
"bFilter": true,
54+
"bSort": true,
55+
"bInfo": false,
56+
"bAutoWidth": true
57+
});
58+
59+
$('#thePartialViewLocations').dataTable(
60+
{
61+
"aaSorting": [[0, "desc"]],
62+
"bPaginate": false,
63+
"bLengthChange": false,
64+
"bFilter": true,
65+
"bSort": true,
66+
"bInfo": false,
67+
"bAutoWidth": true
68+
});
69+
});
70+
</script>
71+
</asp:Content>

0 commit comments

Comments
 (0)