Skip to content

Commit c3b1aa5

Browse files
Added IoC viewer
1 parent 3b2f93c commit c3b1aa5

File tree

10 files changed

+73
-114
lines changed

10 files changed

+73
-114
lines changed

DeveloperTools/Controllers/IOCController.cs

Lines changed: 0 additions & 70 deletions
This file was deleted.

tests/temp/IOC/Index.cshtml renamed to DeveloperTools/EPiServer.DeveloperTools.Views/Views/IOC/Index.cshtml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
@using DeveloperTools.Models
2-
@using EPiServer.Shell
3-
@inherits System.Web.Mvc.WebViewPage<DeveloperTools.Models.IOCModel>
4-
5-
@{
6-
Layout = Paths.ToResource("EPiServer.DeveloperTools", "Views/Shared/DevToolsMaster.cshtml");
7-
}
1+
@model EPiServer.DeveloperTools.Features.IoC.IOCModel
82

93
<div class="epi-contentArea">
104
<h1 class="EP-prefix">IoC Container</h1>
115
<p>
12-
Dumps all types registered in the StructureMap container used by EPiServer.
6+
Dumps all types registered in the Dependency Injection container (aka Service Collection) used by Optimizely.
137
</p>
148
</div>
159
<div class="epi-formArea">
@@ -18,8 +12,9 @@
1812
<tr>
1913
<th align="left">PluginType</th>
2014
<th align="left">ConcreteType</th>
15+
<th align="left">ImplementationFactory</th>
16+
<th align="left">ImplementationInstance</th>
2117
<th align="left">Scope</th>
22-
<th>Is Default</th>
2318
</tr>
2419
</thead>
2520
<tbody>
@@ -28,26 +23,16 @@
2823
<tr>
2924
<td>@entry.PluginType</td>
3025
<td>@entry.ConcreteType</td>
26+
<td>@entry.ImplementationFactory</td>
27+
<td>@entry.ImplementationInstance</td>
3128
<td>@entry.Scope</td>
32-
<td>@entry.IsDefault</td>
3329
</tr>
3430
}
3531
</tbody>
3632
</table>
3733
</div>
3834

39-
@if (Model.LoadingErrors.Any())
40-
{
41-
<b>Retrieval errors:</b>
42-
<ul>
43-
@foreach (var message in Model.LoadingErrors)
44-
{
45-
<li>@message<br/>________________________________________________________________</li>
46-
}
47-
</ul>
48-
}
49-
50-
@section Scripts {
35+
@section AdditionalScripts {
5136
<script>
5237
$(document).ready(function () {
5338
$('#theList').dataTable(

DeveloperTools/EPiServer.DeveloperTools.Views/Views/StartupPerf/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@model IEnumerable<EPiServer.DeveloperTools.Models.TimeMetersModel>
1+
@model IEnumerable<EPiServer.DeveloperTools.Features.StartupPerf.TimeMetersModel>
22

33
<div class="epi-contentArea">
44
<h1 class="EP-prefix">Startup Performance</h1>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Linq;
2+
using DeveloperTools.Controllers;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace EPiServer.DeveloperTools.Features.IoC
6+
{
7+
public class IOCController : DeveloperToolsController
8+
{
9+
private readonly ServiceCollectionClosure _closure;
10+
11+
public IOCController(ServiceCollectionClosure closure)
12+
{
13+
_closure = closure;
14+
}
15+
16+
public ActionResult Index()
17+
{
18+
var model = new IOCModel();
19+
20+
var services = _closure.Services;
21+
22+
model.IOCEntries = services.Select(s => new IOCEntry
23+
{
24+
PluginType = s.ServiceType.FullName,
25+
ConcreteType = s.ImplementationType?.FullName,
26+
ImplementationFactory = s.ImplementationFactory?.Method.ToString(),
27+
ImplementationInstance = s.ImplementationInstance?.GetType().FullName,
28+
Scope = s.Lifetime.ToString()
29+
});
30+
31+
return View(model);
32+
}
33+
}
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
3+
namespace EPiServer.DeveloperTools.Features.IoC;
4+
5+
public class IOCModel
6+
{
7+
public IEnumerable<IOCEntry> IOCEntries { get; set; } = new List<IOCEntry>();
8+
}
9+
10+
public class IOCEntry
11+
{
12+
public bool IsDefault { get; set; }
13+
public string PluginType { get; set; }
14+
public string ConcreteType { get; set; }
15+
public string ImplementationFactory { get; set; }
16+
public string Scope { get; set; }
17+
public string ImplementationInstance { get; set; }
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
3+
namespace EPiServer.DeveloperTools.Features.IoC;
4+
5+
public class ServiceCollectionClosure
6+
{
7+
public ServiceCollectionClosure(IServiceCollection services) { Services = services; }
8+
public IServiceCollection Services { get; }
9+
}

DeveloperTools/Controllers/StartupPerfController.cs renamed to DeveloperTools/Features/StartupPerf/StartupPerfController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using EPiServer.Cms.Shell.UI.Controllers.Internal;
4-
using EPiServer.DeveloperTools.Models;
54
using EPiServer.Framework.Initialization;
65
using Microsoft.AspNetCore.Mvc;
76

8-
namespace EPiServer.DeveloperTools.Controllers;
7+
namespace EPiServer.DeveloperTools.Features.StartupPerf;
98

109
public class StartupPerfController : BaseController
1110
{

DeveloperTools/Models/TimeMetersModel.cs renamed to DeveloperTools/Features/StartupPerf/TimeMetersModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace EPiServer.DeveloperTools.Models;
1+
namespace EPiServer.DeveloperTools.Features.StartupPerf;
22

33
public class TimeMetersModel
44
{

DeveloperTools/Infrastructure/Configuration/IServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Linq;
33
using DeveloperTools;
4+
using EPiServer.DeveloperTools.Features.IoC;
45
using EPiServer.Shell.Modules;
56
using Microsoft.AspNetCore.Authorization;
67
using Microsoft.Extensions.Configuration;
@@ -29,6 +30,7 @@ public static IServiceCollection AddOptimizelyDeveloperTools(
2930
Action<OptimizelyDeveloperToolsOptions> setupAction,
3031
Action<AuthorizationPolicyBuilder> configurePolicy)
3132
{
33+
services.AddSingleton(new ServiceCollectionClosure(services));
3234

3335
services.Configure<ProtectedModuleOptions>(
3436
pm =>

DeveloperTools/Models/IOCModel.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)