performance optimizations to avoid use of reflection ( thanks to @chlupac for this suggestion )
This commit is contained in:
parent
b59e2533ea
commit
52b2c876a4
|
@ -123,8 +123,8 @@
|
||||||
_settingsModuleType = Type.GetType(ModuleState.ModuleType);
|
_settingsModuleType = Type.GetType(ModuleState.ModuleType);
|
||||||
if (_settingsModuleType != null)
|
if (_settingsModuleType != null)
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(_settingsModuleType);
|
var moduleobject = Activator.CreateInstance(_settingsModuleType) as IModuleControl;
|
||||||
_settingstitle = (string)_settingsModuleType.GetProperty("Title").GetValue(moduleobject, null);
|
_settingstitle = moduleobject.Title;
|
||||||
if (string.IsNullOrEmpty(_settingstitle))
|
if (string.IsNullOrEmpty(_settingstitle))
|
||||||
{
|
{
|
||||||
_settingstitle = "Other Settings";
|
_settingstitle = "Other Settings";
|
||||||
|
|
|
@ -109,8 +109,8 @@
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(moduleType);
|
var moduleobject = Activator.CreateInstance(moduleType) as IModuleControl;
|
||||||
security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
security = moduleobject.SecurityAccessLevel;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,8 +101,8 @@
|
||||||
var moduleType = Type.GetType(typename);
|
var moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(moduleType);
|
var moduleobject = Activator.CreateInstance(moduleType) as IModuleControl;
|
||||||
security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
security = moduleobject.SecurityAccessLevel;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -361,21 +361,20 @@
|
||||||
|
|
||||||
string panes = "";
|
string panes = "";
|
||||||
Type themetype = Type.GetType(page.ThemeType);
|
Type themetype = Type.GetType(page.ThemeType);
|
||||||
var themeobject = Activator.CreateInstance(themetype);
|
var themeobject = Activator.CreateInstance(themetype) as IThemeControl;
|
||||||
if (themeobject != null)
|
if (themeobject != null)
|
||||||
{
|
{
|
||||||
panes = (string)themetype.GetProperty("Panes").GetValue(themeobject, null);
|
panes = themeobject.Panes;
|
||||||
var resources = (List<Resource>)themetype.GetProperty("Resources").GetValue(themeobject, null);
|
page.Resources = ManagePageResources(page.Resources, themeobject.Resources);
|
||||||
page.Resources = ManagePageResources(page.Resources, resources);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(page.LayoutType))
|
if (!string.IsNullOrEmpty(page.LayoutType))
|
||||||
{
|
{
|
||||||
themetype = Type.GetType(page.LayoutType);
|
Type layouttype = Type.GetType(page.LayoutType);
|
||||||
themeobject = Activator.CreateInstance(themetype);
|
var layoutobject = Activator.CreateInstance(layouttype) as ILayoutControl;
|
||||||
if (themeobject != null)
|
if (layoutobject != null)
|
||||||
{
|
{
|
||||||
panes = (string)themetype.GetProperty("Panes").GetValue(themeobject, null);
|
panes = layoutobject.Panes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,19 +433,24 @@
|
||||||
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, control);
|
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, control);
|
||||||
}
|
}
|
||||||
Type moduletype = Type.GetType(typename);
|
Type moduletype = Type.GetType(typename);
|
||||||
if (moduletype != null)
|
|
||||||
|
// ensure component implements IModuleControl
|
||||||
|
if (moduletype != null && !moduletype.GetInterfaces().Contains(typeof(IModuleControl)))
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(moduletype);
|
module.ModuleType = "";
|
||||||
var resources = (List<Resource>)moduletype.GetProperty("Resources").GetValue(moduleobject, null);
|
}
|
||||||
page.Resources = ManagePageResources(page.Resources, resources);
|
if (moduletype != null && module.ModuleType != "")
|
||||||
|
{
|
||||||
|
var moduleobject = Activator.CreateInstance(moduletype) as IModuleControl;
|
||||||
|
page.Resources = ManagePageResources(page.Resources, moduleobject.Resources);
|
||||||
|
|
||||||
// additional metadata needed for admin components
|
// additional metadata needed for admin components
|
||||||
if (module.ModuleId == moduleid && control != "")
|
if (module.ModuleId == moduleid && control != "")
|
||||||
{
|
{
|
||||||
module.SecurityAccessLevel = (SecurityAccessLevel)moduletype.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
module.SecurityAccessLevel = moduleobject.SecurityAccessLevel;
|
||||||
module.ControlTitle = (string)moduletype.GetProperty("Title").GetValue(moduleobject);
|
module.ControlTitle = moduleobject.Title;
|
||||||
module.Actions = (string)moduletype.GetProperty("Actions").GetValue(moduleobject);
|
module.Actions = moduleobject.Actions;
|
||||||
module.UseAdminContainer = (bool)moduletype.GetProperty("UseAdminContainer").GetValue(moduleobject);
|
module.UseAdminContainer = moduleobject.UseAdminContainer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,8 +213,8 @@ namespace Oqtane.Repository
|
||||||
if (moduletype != null)
|
if (moduletype != null)
|
||||||
{
|
{
|
||||||
// get property values from IModule
|
// get property values from IModule
|
||||||
var moduleobject = Activator.CreateInstance(moduletype);
|
var moduleobject = Activator.CreateInstance(moduletype) as IModule;
|
||||||
moduledefinition = (ModuleDefinition) moduletype.GetProperty("ModuleDefinition").GetValue(moduleobject);
|
moduledefinition = moduleobject.ModuleDefinition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -261,8 +261,8 @@ namespace Oqtane.Repository
|
||||||
|
|
||||||
moduledefinition = moduledefinitions[index];
|
moduledefinition = moduledefinitions[index];
|
||||||
// actions
|
// actions
|
||||||
var modulecontrolobject = Activator.CreateInstance(modulecontroltype);
|
var modulecontrolobject = Activator.CreateInstance(modulecontroltype) as IModuleControl;
|
||||||
string actions = (string) modulecontroltype.GetProperty("Actions")?.GetValue(modulecontrolobject);
|
string actions = modulecontrolobject.Actions;
|
||||||
if (!string.IsNullOrEmpty(actions))
|
if (!string.IsNullOrEmpty(actions))
|
||||||
{
|
{
|
||||||
foreach (string action in actions.Split(','))
|
foreach (string action in actions.Split(','))
|
||||||
|
|
|
@ -66,8 +66,8 @@ namespace Oqtane.Repository
|
||||||
.Where(item => item.GetInterfaces().Contains(typeof(ITheme))).FirstOrDefault();
|
.Where(item => item.GetInterfaces().Contains(typeof(ITheme))).FirstOrDefault();
|
||||||
if (themetype != null)
|
if (themetype != null)
|
||||||
{
|
{
|
||||||
var themeobject = Activator.CreateInstance(themetype);
|
var themeobject = Activator.CreateInstance(themetype) as ITheme;
|
||||||
theme = (Theme)themetype.GetProperty("Theme").GetValue(themeobject);
|
theme = themeobject.Theme;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user