performance optimizations to avoid use of reflection ( thanks to @chlupac for this suggestion )

This commit is contained in:
Shaun Walker
2020-05-19 13:39:39 -04:00
parent b59e2533ea
commit 52b2c876a4
6 changed files with 35 additions and 31 deletions

View File

@ -213,8 +213,8 @@ namespace Oqtane.Repository
if (moduletype != null)
{
// get property values from IModule
var moduleobject = Activator.CreateInstance(moduletype);
moduledefinition = (ModuleDefinition) moduletype.GetProperty("ModuleDefinition").GetValue(moduleobject);
var moduleobject = Activator.CreateInstance(moduletype) as IModule;
moduledefinition = moduleobject.ModuleDefinition;
}
else
{
@ -261,8 +261,8 @@ namespace Oqtane.Repository
moduledefinition = moduledefinitions[index];
// actions
var modulecontrolobject = Activator.CreateInstance(modulecontroltype);
string actions = (string) modulecontroltype.GetProperty("Actions")?.GetValue(modulecontrolobject);
var modulecontrolobject = Activator.CreateInstance(modulecontroltype) as IModuleControl;
string actions = modulecontrolobject.Actions;
if (!string.IsNullOrEmpty(actions))
{
foreach (string action in actions.Split(','))

View File

@ -66,8 +66,8 @@ namespace Oqtane.Repository
.Where(item => item.GetInterfaces().Contains(typeof(ITheme))).FirstOrDefault();
if (themetype != null)
{
var themeobject = Activator.CreateInstance(themetype);
theme = (Theme)themetype.GetProperty("Theme").GetValue(themeobject);
var themeobject = Activator.CreateInstance(themetype) as ITheme;
theme = themeobject.Theme;
}
else
{