Skip to content

Commit 550907b

Browse files
authored
Merge pull request #8 from valdisiljuconoks/master
EPiServer v10 support
2 parents 865cfa2 + d10175e commit 550907b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1786
-781
lines changed
42.2 KB
Binary file not shown.

.nuget/NuGet.exe

988 KB
Binary file not shown.

.nuget/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="NuGet.CommandLine" version="2.2.1" />
4-
<package id="NuGet.CommandLine" version="2.5.0" />
3+
<package id="NuGet.CommandLine" version="2.8.1" />
54
</packages>

.vs/config/applicationhost.config

Lines changed: 1031 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Web;
5-
using System.Web.Mvc;
6-
using EPiServer.Shell.Navigation;
7-
using DeveloperTools.Models;
8-
using EPiServer.Framework.Initialization;
9-
using StructureMap;
10-
using EPiServer.ServiceLocation;
1+
using System.Web.Mvc;
112
using EPiServer.DataAbstraction;
12-
using EPiServer.DataAbstraction.RuntimeModel;
13-
using EPiServer.Core;
14-
using EPiServer.Security;
15-
using System.Reflection;
16-
using System.Runtime.Serialization;
17-
using System.Runtime.Serialization.Formatters.Binary;
18-
using System.IO;
3+
using EPiServer.ServiceLocation;
194

205
namespace DeveloperTools.Controllers
216
{
22-
237
public class ContentTypeAnalyzerController : DeveloperToolsController
248
{
25-
269
public ActionResult Index()
2710
{
2811
return View(ServiceLocator.Current.GetInstance<ContentTypeModelRepository>().List());
2912
}
30-
3113
}
3214
}

DeveloperTools/Controllers/DeveloperToolsController.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using EPiServer.Security;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Web;
1+
using System;
62
using System.Web.Mvc;
3+
using EPiServer.Security;
74

85
namespace DeveloperTools.Controllers
96
{
@@ -15,6 +12,7 @@ protected override void OnAuthorization(AuthorizationContext filterContext)
1512
{
1613
throw new UnauthorizedAccessException();
1714
}
15+
1816
base.OnAuthorization(filterContext);
1917
}
2018
}

DeveloperTools/Controllers/IOCController.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Web;
4+
using System.Reflection;
55
using System.Web.Mvc;
6-
using EPiServer.Shell.Navigation;
76
using DeveloperTools.Models;
87
using EPiServer.Framework.Initialization;
98
using StructureMap;
109

1110
namespace DeveloperTools.Controllers
1211
{
13-
1412
public class IOCController : DeveloperToolsController
1513
{
1614
public ActionResult Index()
1715
{
16+
var ie = (InitializationEngine) typeof(InitializationModule).GetField("_engine", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
17+
var container = (IContainer) ie.GetType().GetProperty("Container", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(ie, new object[0]);
1818

19-
var ie = ((InitializationEngine)typeof(EPiServer.Framework.Initialization.InitializationModule).GetField("_engine", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null));
20-
IContainer container = (IContainer)ie.GetType().GetProperty("Container", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(ie, new object[0]);
21-
22-
List<IOCEntry> iocEntries = new List<IOCEntry>();
23-
List<string> typeErrors = new List<string>();
19+
var iocEntries = new List<IOCEntry>();
20+
var typeErrors = new List<string>();
2421

2522
foreach (var plugin in container.Model.PluginTypes)
2623
{
2724
try
2825
{
29-
Type defaultType = plugin.Default != null ? plugin.Default.ReturnedType : null;
30-
if (plugin.Default != null && defaultType == null)
26+
var defaultType = plugin.Default?.ReturnedType;
27+
if(plugin.Default != null && defaultType == null)
3128
{
3229
defaultType = container.GetInstance(plugin.Default.PluginType, plugin.Default.Name).GetType();
3330
}
3431

3532
foreach (var entry in plugin.Instances.Where(i => i != null))
3633
{
37-
Type concreteType = entry.ReturnedType;
38-
if (concreteType == null && entry.PluginType.ContainsGenericParameters == false)
34+
var concreteType = entry.ReturnedType;
35+
if(concreteType == null && entry.PluginType.ContainsGenericParameters == false)
3936
{
4037
concreteType = container.GetInstance(entry.PluginType, entry.Name).GetType();
4138
}
4239

43-
iocEntries.Add(new IOCEntry()
44-
{
45-
PluginType = entry.PluginType == null ? "null" : entry.PluginType.FullName + "," + entry.PluginType.Assembly.FullName,
46-
ConcreteType = concreteType == null ? "null" : concreteType.FullName + "," + concreteType.Assembly.FullName,
47-
Scope = plugin.Lifecycle.ToString(),
48-
IsDefault = defaultType == concreteType
49-
});
40+
iocEntries.Add(new IOCEntry
41+
{
42+
PluginType = entry.PluginType == null ? "null" : $"{entry.PluginType.FullName},{entry.PluginType.Assembly.FullName}",
43+
ConcreteType = concreteType == null ? "null" : $"{concreteType.FullName},{concreteType.Assembly.FullName}",
44+
Scope = plugin.Lifecycle.ToString(),
45+
IsDefault = defaultType == concreteType
46+
});
5047
}
5148
}
5249
catch (Exception ex)
@@ -55,7 +52,7 @@ public ActionResult Index()
5552
}
5653
}
5754

58-
var model = new IOCModel() { IOCEntries = iocEntries, LoadingErrors = typeErrors };
55+
var model = new IOCModel { IOCEntries = iocEntries, LoadingErrors = typeErrors };
5956

6057
return View(model);
6158
}
Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Linq;
4-
using System.Web;
5+
using System.Reflection;
56
using System.Web.Mvc;
6-
using EPiServer.Shell.Navigation;
77
using DeveloperTools.Models;
8-
using EPiServer.Framework.Initialization;
9-
using StructureMap;
10-
using System.Reflection;
11-
using System.Diagnostics;
128

139
namespace DeveloperTools.Controllers
1410
{
@@ -20,36 +16,36 @@ public ActionResult Index()
2016
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
2117
{
2218
string fileVersion = null;
23-
string location = assembly.IsDynamic ? "dynamic" : String.IsNullOrEmpty(assembly.Location) ? new Uri(assembly.CodeBase).LocalPath : assembly.Location;
19+
var location = assembly.IsDynamic ? "dynamic" : string.IsNullOrEmpty(assembly.Location) ? new Uri(assembly.CodeBase).LocalPath : assembly.Location;
2420

25-
if (!assembly.IsDynamic)
21+
if(!assembly.IsDynamic)
2622
{
27-
AssemblyFileVersionAttribute fileVersionAttribute = (AssemblyFileVersionAttribute)assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).FirstOrDefault();
28-
if (fileVersionAttribute != null)
23+
var fileVersionAttribute = (AssemblyFileVersionAttribute) assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).FirstOrDefault();
24+
if(fileVersionAttribute != null)
2925
{
3026
fileVersion = fileVersionAttribute.Version;
3127
}
3228

33-
if (fileVersion == null)
29+
if(fileVersion == null)
3430
{
35-
FileVersionInfo versionInfo = assembly.IsDynamic ? null : FileVersionInfo.GetVersionInfo(location);
36-
if (versionInfo != null)
31+
var versionInfo = assembly.IsDynamic ? null : FileVersionInfo.GetVersionInfo(location);
32+
if(versionInfo != null)
3733
{
3834
fileVersion = versionInfo.FileVersion;
3935
}
4036
}
4137
}
4238

43-
assemblies.Add(new AssemblyInfo()
44-
{
45-
Name = assembly.FullName,
46-
AssemblyVersion = assembly.GetName().Version.ToString(),
47-
FileVersion = fileVersion ?? assembly.GetName().Version.ToString(),
48-
Location = assembly.IsDynamic ? "dynamic" : location
49-
});
39+
assemblies.Add(new AssemblyInfo
40+
{
41+
Name = assembly.FullName,
42+
AssemblyVersion = assembly.GetName().Version.ToString(),
43+
FileVersion = fileVersion ?? assembly.GetName().Version.ToString(),
44+
Location = assembly.IsDynamic ? "dynamic" : location
45+
});
5046
}
5147

52-
return View(new AssembliesModel() { Assemblies = assemblies });
48+
return View(new AssembliesModel { Assemblies = assemblies });
5349
}
5450
}
5551
}

DeveloperTools/Controllers/LogViewerController.cs

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Web;
54
using System.Web.Mvc;
6-
using EPiServer.Shell.Gadgets;
7-
using log4net.Appender;
8-
using log4net.Repository.Hierarchy;
5+
using DeveloperTools.Core;
6+
using DeveloperTools.Models;
97
using log4net;
108
using log4net.Core;
11-
using System.Collections.Specialized;
12-
using EPiServer.Shell.Navigation;
13-
using DeveloperTools.Models;
14-
using DeveloperTools.Core;
9+
using log4net.Repository.Hierarchy;
1510

1611
namespace DeveloperTools.Controllers
1712
{
1813
public class LogViewerController : DeveloperToolsController
1914
{
20-
private RollingMemoryAppender _memoryAppender = null;
21-
private Hierarchy _hierarchy = (Hierarchy)LogManager.GetRepository();
15+
private readonly Hierarchy _hierarchy = (Hierarchy) LogManager.GetRepository();
16+
private RollingMemoryAppender _memoryAppender;
2217

2318
public LogViewerController()
2419
{
@@ -28,57 +23,57 @@ public LogViewerController()
2823
[HttpGet]
2924
public ActionResult Index()
3025
{
31-
LogSettingAndEvents logSettingAndEvents = new LogSettingAndEvents();
32-
logSettingAndEvents.IsStarted = _memoryAppender != null ? _memoryAppender.IsStarted : false;
33-
logSettingAndEvents.LoggingEvents = _memoryAppender == null ? Enumerable.Empty<LoggingEvent>() : _memoryAppender.GetEvents();
26+
var logSettingAndEvents = new LogSettingAndEvents
27+
{
28+
IsStarted = _memoryAppender?.IsStarted ?? false,
29+
LoggingEvents = _memoryAppender == null ? Enumerable.Empty<LoggingEvent>() : _memoryAppender.GetEvents()
30+
};
3431

3532
return View("Show", logSettingAndEvents);
3633
}
3734

3835
[HttpPost, ActionName("Index")]
3936
public ActionResult Filter(LoggerSettings loggerSetting)
4037
{
41-
LogSettingAndEvents logSettingAndEvents = new LogSettingAndEvents();
42-
logSettingAndEvents.IsStarted = _memoryAppender != null ? _memoryAppender.IsStarted : false;
43-
logSettingAndEvents.LoggingEvents = GetFilteredEvents(loggerSetting);
44-
logSettingAndEvents.LoggerSetting = loggerSetting;
38+
var logSettingAndEvents = new LogSettingAndEvents
39+
{
40+
IsStarted = _memoryAppender?.IsStarted ?? false,
41+
LoggingEvents = GetFilteredEvents(loggerSetting),
42+
LoggerSetting = loggerSetting
43+
};
44+
4545
return View("Show", logSettingAndEvents);
4646
}
4747

4848
public ActionResult Start()
4949
{
50-
if (_memoryAppender == null)
51-
{
50+
if(_memoryAppender == null)
5251
CreateDefaultMemoryAppender();
53-
}
54-
if (_memoryAppender != null)
55-
{
52+
53+
if(_memoryAppender != null)
5654
_memoryAppender.IsStarted = true;
57-
}
55+
5856
return RedirectToAction("Index");
5957
}
6058

6159
public ActionResult Stop()
6260
{
63-
if (_memoryAppender != null)
64-
{
61+
if(_memoryAppender != null)
6562
_memoryAppender.IsStarted = false;
66-
}
63+
6764
return RedirectToAction("Index");
6865
}
6966

70-
7167
private void InitMessageLogger()
7268
{
73-
AppenderCollection appenderCollection;
74-
appenderCollection = ((Logger)_hierarchy.Root).Appenders;
69+
var appenderCollection = _hierarchy.Root.Appenders;
7570

76-
foreach (IAppender item in appenderCollection)
71+
foreach (var item in appenderCollection)
7772
{
7873
var ma = item as RollingMemoryAppender;
79-
if (ma != null)
74+
if(ma != null)
8075
{
81-
_memoryAppender = (RollingMemoryAppender)item;
76+
_memoryAppender = (RollingMemoryAppender) item;
8277
_memoryAppender.ActivateOptions();
8378
return;
8479
}
@@ -87,41 +82,44 @@ private void InitMessageLogger()
8782

8883
private void CreateDefaultMemoryAppender()
8984
{
90-
_memoryAppender = new RollingMemoryAppender();
91-
_memoryAppender.Name = "DeveloperToolsLogViewer";
85+
_memoryAppender = new RollingMemoryAppender { Name = "DeveloperToolsLogViewer" };
9286
_memoryAppender.ActivateOptions();
93-
log4net.Repository.Hierarchy.Hierarchy repository = LogManager.GetRepository() as Hierarchy;
94-
repository.Root.AddAppender(_memoryAppender);
95-
repository.Root.Level = Level.All;
96-
repository.Configured = true;
97-
repository.RaiseConfigurationChanged(EventArgs.Empty);
87+
var repository = LogManager.GetRepository() as Hierarchy;
88+
89+
if(repository != null)
90+
{
91+
repository.Root.AddAppender(_memoryAppender);
92+
repository.Root.Level = Level.All;
93+
repository.Configured = true;
94+
repository.RaiseConfigurationChanged(EventArgs.Empty);
95+
}
9896
}
9997

10098
private IEnumerable<LoggingEvent> GetFilteredEvents(LoggerSettings loggerSetting)
10199
{
102-
if (_memoryAppender == null)
100+
if(_memoryAppender == null)
103101
{
104102
return Enumerable.Empty<LoggingEvent>();
105103
}
106104

107105
IEnumerable<LoggingEvent> res = _memoryAppender.GetEvents().Distinct().Where(l => l.Level >= loggerSetting.Level).OrderBy(l => l.TimeStamp);
108106

109-
if (res.Count() > 0 && !String.IsNullOrEmpty(loggerSetting.LoggerName))
107+
if(res.Any() && !string.IsNullOrEmpty(loggerSetting.LoggerName))
110108
{
111-
res = res.Where<LoggingEvent>(l => l.LoggerName.Contains(loggerSetting.LoggerName));
109+
res = res.Where(l => l.LoggerName.Contains(loggerSetting.LoggerName));
112110
}
113111

114-
if (res.Count() > 0 && !String.IsNullOrEmpty(loggerSetting.ThreadName))
112+
if(res.Any() && !string.IsNullOrEmpty(loggerSetting.ThreadName))
115113
{
116114
res = res.Where(l => l.ThreadName == loggerSetting.ThreadName);
117115
}
118116

119-
if (res.Count() > 0 && !String.IsNullOrEmpty(loggerSetting.UserName))
117+
if(res.Any() && !string.IsNullOrEmpty(loggerSetting.UserName))
120118
{
121119
res = res.Where(l => l.UserName == loggerSetting.UserName);
122120
}
123121

124-
if (res.Count() > 0)
122+
if(res.Any())
125123
{
126124
res = res.Where(l => ((l.TimeStamp.Ticks >= loggerSetting.StartDate.Ticks) && (l.TimeStamp.Ticks <= loggerSetting.EndDate.Ticks)));
127125
}

0 commit comments

Comments
 (0)