Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .nuget/EPiServer.DeveloperTools.2.0.0.nupkg
Binary file not shown.
Binary file modified .nuget/NuGet.exe
Binary file not shown.
3 changes: 1 addition & 2 deletions .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NuGet.CommandLine" version="2.2.1" />
<package id="NuGet.CommandLine" version="2.5.0" />
<package id="NuGet.CommandLine" version="2.8.1" />
</packages>
1,031 changes: 1,031 additions & 0 deletions .vs/config/applicationhost.config

Large diffs are not rendered by default.

22 changes: 2 additions & 20 deletions DeveloperTools/Controllers/ContentTypeAnalyzerController.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EPiServer.Shell.Navigation;
using DeveloperTools.Models;
using EPiServer.Framework.Initialization;
using StructureMap;
using EPiServer.ServiceLocation;
using System.Web.Mvc;
using EPiServer.DataAbstraction;
using EPiServer.DataAbstraction.RuntimeModel;
using EPiServer.Core;
using EPiServer.Security;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using EPiServer.ServiceLocation;

namespace DeveloperTools.Controllers
{

public class ContentTypeAnalyzerController : DeveloperToolsController
{

public ActionResult Index()
{
return View(ServiceLocator.Current.GetInstance<ContentTypeModelRepository>().List());
}

}
}
8 changes: 3 additions & 5 deletions DeveloperTools/Controllers/DeveloperToolsController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using EPiServer.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System;
using System.Web.Mvc;
using EPiServer.Security;

namespace DeveloperTools.Controllers
{
Expand All @@ -15,6 +12,7 @@ protected override void OnAuthorization(AuthorizationContext filterContext)
{
throw new UnauthorizedAccessException();
}

base.OnAuthorization(filterContext);
}
}
Expand Down
37 changes: 17 additions & 20 deletions DeveloperTools/Controllers/IOCController.cs
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;
using System.Web.Mvc;
using EPiServer.Shell.Navigation;
using DeveloperTools.Models;
using EPiServer.Framework.Initialization;
using StructureMap;

namespace DeveloperTools.Controllers
{

public class IOCController : DeveloperToolsController
{
public ActionResult Index()
{
var ie = (InitializationEngine) typeof(InitializationModule).GetField("_engine", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
var container = (IContainer) ie.GetType().GetProperty("Container", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(ie, new object[0]);

var ie = ((InitializationEngine)typeof(EPiServer.Framework.Initialization.InitializationModule).GetField("_engine", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null));
IContainer container = (IContainer)ie.GetType().GetProperty("Container", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(ie, new object[0]);

List<IOCEntry> iocEntries = new List<IOCEntry>();
List<string> typeErrors = new List<string>();
var iocEntries = new List<IOCEntry>();
var typeErrors = new List<string>();

foreach (var plugin in container.Model.PluginTypes)
{
try
{
Type defaultType = plugin.Default != null ? plugin.Default.ReturnedType : null;
if (plugin.Default != null && defaultType == null)
var defaultType = plugin.Default?.ReturnedType;
if(plugin.Default != null && defaultType == null)
{
defaultType = container.GetInstance(plugin.Default.PluginType, plugin.Default.Name).GetType();
}

foreach (var entry in plugin.Instances.Where(i => i != null))
{
Type concreteType = entry.ReturnedType;
if (concreteType == null && entry.PluginType.ContainsGenericParameters == false)
var concreteType = entry.ReturnedType;
if(concreteType == null && entry.PluginType.ContainsGenericParameters == false)
{
concreteType = container.GetInstance(entry.PluginType, entry.Name).GetType();
}

iocEntries.Add(new IOCEntry()
{
PluginType = entry.PluginType == null ? "null" : entry.PluginType.FullName + "," + entry.PluginType.Assembly.FullName,
ConcreteType = concreteType == null ? "null" : concreteType.FullName + "," + concreteType.Assembly.FullName,
Scope = plugin.Lifecycle.ToString(),
IsDefault = defaultType == concreteType
});
iocEntries.Add(new IOCEntry
{
PluginType = entry.PluginType == null ? "null" : $"{entry.PluginType.FullName},{entry.PluginType.Assembly.FullName}",
ConcreteType = concreteType == null ? "null" : $"{concreteType.FullName},{concreteType.Assembly.FullName}",
Scope = plugin.Lifecycle.ToString(),
IsDefault = defaultType == concreteType
});
}
}
catch (Exception ex)
Expand All @@ -55,7 +52,7 @@ public ActionResult Index()
}
}

var model = new IOCModel() { IOCEntries = iocEntries, LoadingErrors = typeErrors };
var model = new IOCModel { IOCEntries = iocEntries, LoadingErrors = typeErrors };

return View(model);
}
Expand Down
38 changes: 17 additions & 21 deletions DeveloperTools/Controllers/LoadedAssembliesController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Reflection;
using System.Web.Mvc;
using EPiServer.Shell.Navigation;
using DeveloperTools.Models;
using EPiServer.Framework.Initialization;
using StructureMap;
using System.Reflection;
using System.Diagnostics;

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

if (!assembly.IsDynamic)
if(!assembly.IsDynamic)
{
AssemblyFileVersionAttribute fileVersionAttribute = (AssemblyFileVersionAttribute)assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).FirstOrDefault();
if (fileVersionAttribute != null)
var fileVersionAttribute = (AssemblyFileVersionAttribute) assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).FirstOrDefault();
if(fileVersionAttribute != null)
{
fileVersion = fileVersionAttribute.Version;
}

if (fileVersion == null)
if(fileVersion == null)
{
FileVersionInfo versionInfo = assembly.IsDynamic ? null : FileVersionInfo.GetVersionInfo(location);
if (versionInfo != null)
var versionInfo = assembly.IsDynamic ? null : FileVersionInfo.GetVersionInfo(location);
if(versionInfo != null)
{
fileVersion = versionInfo.FileVersion;
}
}
}

assemblies.Add(new AssemblyInfo()
{
Name = assembly.FullName,
AssemblyVersion = assembly.GetName().Version.ToString(),
FileVersion = fileVersion ?? assembly.GetName().Version.ToString(),
Location = assembly.IsDynamic ? "dynamic" : location
});
assemblies.Add(new AssemblyInfo
{
Name = assembly.FullName,
AssemblyVersion = assembly.GetName().Version.ToString(),
FileVersion = fileVersion ?? assembly.GetName().Version.ToString(),
Location = assembly.IsDynamic ? "dynamic" : location
});
}

return View(new AssembliesModel() { Assemblies = assemblies });
return View(new AssembliesModel { Assemblies = assemblies });
}
}
}
88 changes: 43 additions & 45 deletions DeveloperTools/Controllers/LogViewerController.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EPiServer.Shell.Gadgets;
using log4net.Appender;
using log4net.Repository.Hierarchy;
using DeveloperTools.Core;
using DeveloperTools.Models;
using log4net;
using log4net.Core;
using System.Collections.Specialized;
using EPiServer.Shell.Navigation;
using DeveloperTools.Models;
using DeveloperTools.Core;
using log4net.Repository.Hierarchy;

namespace DeveloperTools.Controllers
{
public class LogViewerController : DeveloperToolsController
{
private RollingMemoryAppender _memoryAppender = null;
private Hierarchy _hierarchy = (Hierarchy)LogManager.GetRepository();
private readonly Hierarchy _hierarchy = (Hierarchy) LogManager.GetRepository();
private RollingMemoryAppender _memoryAppender;

public LogViewerController()
{
Expand All @@ -28,57 +23,57 @@ public LogViewerController()
[HttpGet]
public ActionResult Index()
{
LogSettingAndEvents logSettingAndEvents = new LogSettingAndEvents();
logSettingAndEvents.IsStarted = _memoryAppender != null ? _memoryAppender.IsStarted : false;
logSettingAndEvents.LoggingEvents = _memoryAppender == null ? Enumerable.Empty<LoggingEvent>() : _memoryAppender.GetEvents();
var logSettingAndEvents = new LogSettingAndEvents
{
IsStarted = _memoryAppender?.IsStarted ?? false,
LoggingEvents = _memoryAppender == null ? Enumerable.Empty<LoggingEvent>() : _memoryAppender.GetEvents()
};

return View("Show", logSettingAndEvents);
}

[HttpPost, ActionName("Index")]
public ActionResult Filter(LoggerSettings loggerSetting)
{
LogSettingAndEvents logSettingAndEvents = new LogSettingAndEvents();
logSettingAndEvents.IsStarted = _memoryAppender != null ? _memoryAppender.IsStarted : false;
logSettingAndEvents.LoggingEvents = GetFilteredEvents(loggerSetting);
logSettingAndEvents.LoggerSetting = loggerSetting;
var logSettingAndEvents = new LogSettingAndEvents
{
IsStarted = _memoryAppender?.IsStarted ?? false,
LoggingEvents = GetFilteredEvents(loggerSetting),
LoggerSetting = loggerSetting
};

return View("Show", logSettingAndEvents);
}

public ActionResult Start()
{
if (_memoryAppender == null)
{
if(_memoryAppender == null)
CreateDefaultMemoryAppender();
}
if (_memoryAppender != null)
{

if(_memoryAppender != null)
_memoryAppender.IsStarted = true;
}

return RedirectToAction("Index");
}

public ActionResult Stop()
{
if (_memoryAppender != null)
{
if(_memoryAppender != null)
_memoryAppender.IsStarted = false;
}

return RedirectToAction("Index");
}


private void InitMessageLogger()
{
AppenderCollection appenderCollection;
appenderCollection = ((Logger)_hierarchy.Root).Appenders;
var appenderCollection = _hierarchy.Root.Appenders;

foreach (IAppender item in appenderCollection)
foreach (var item in appenderCollection)
{
var ma = item as RollingMemoryAppender;
if (ma != null)
if(ma != null)
{
_memoryAppender = (RollingMemoryAppender)item;
_memoryAppender = (RollingMemoryAppender) item;
_memoryAppender.ActivateOptions();
return;
}
Expand All @@ -87,41 +82,44 @@ private void InitMessageLogger()

private void CreateDefaultMemoryAppender()
{
_memoryAppender = new RollingMemoryAppender();
_memoryAppender.Name = "DeveloperToolsLogViewer";
_memoryAppender = new RollingMemoryAppender { Name = "DeveloperToolsLogViewer" };
_memoryAppender.ActivateOptions();
log4net.Repository.Hierarchy.Hierarchy repository = LogManager.GetRepository() as Hierarchy;
repository.Root.AddAppender(_memoryAppender);
repository.Root.Level = Level.All;
repository.Configured = true;
repository.RaiseConfigurationChanged(EventArgs.Empty);
var repository = LogManager.GetRepository() as Hierarchy;

if(repository != null)
{
repository.Root.AddAppender(_memoryAppender);
repository.Root.Level = Level.All;
repository.Configured = true;
repository.RaiseConfigurationChanged(EventArgs.Empty);
}
}

private IEnumerable<LoggingEvent> GetFilteredEvents(LoggerSettings loggerSetting)
{
if (_memoryAppender == null)
if(_memoryAppender == null)
{
return Enumerable.Empty<LoggingEvent>();
}

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

if (res.Count() > 0 && !String.IsNullOrEmpty(loggerSetting.LoggerName))
if(res.Any() && !string.IsNullOrEmpty(loggerSetting.LoggerName))
{
res = res.Where<LoggingEvent>(l => l.LoggerName.Contains(loggerSetting.LoggerName));
res = res.Where(l => l.LoggerName.Contains(loggerSetting.LoggerName));
}

if (res.Count() > 0 && !String.IsNullOrEmpty(loggerSetting.ThreadName))
if(res.Any() && !string.IsNullOrEmpty(loggerSetting.ThreadName))
{
res = res.Where(l => l.ThreadName == loggerSetting.ThreadName);
}

if (res.Count() > 0 && !String.IsNullOrEmpty(loggerSetting.UserName))
if(res.Any() && !string.IsNullOrEmpty(loggerSetting.UserName))
{
res = res.Where(l => l.UserName == loggerSetting.UserName);
}

if (res.Count() > 0)
if(res.Any())
{
res = res.Where(l => ((l.TimeStamp.Ticks >= loggerSetting.StartDate.Ticks) && (l.TimeStamp.Ticks <= loggerSetting.EndDate.Ticks)));
}
Expand Down
Loading