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);
|
||||
if (_settingsModuleType != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(_settingsModuleType);
|
||||
_settingstitle = (string)_settingsModuleType.GetProperty("Title").GetValue(moduleobject, null);
|
||||
var moduleobject = Activator.CreateInstance(_settingsModuleType) as IModuleControl;
|
||||
_settingstitle = moduleobject.Title;
|
||||
if (string.IsNullOrEmpty(_settingstitle))
|
||||
{
|
||||
_settingstitle = "Other Settings";
|
||||
|
|
|
@ -62,9 +62,9 @@
|
|||
[Parameter]
|
||||
public string Class { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true
|
||||
|
||||
|
@ -109,8 +109,8 @@
|
|||
Type moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduleType);
|
||||
security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
var moduleobject = Activator.CreateInstance(moduleType) as IModuleControl;
|
||||
security = moduleobject.SecurityAccessLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -101,8 +101,8 @@
|
|||
var moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduleType);
|
||||
security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
var moduleobject = Activator.CreateInstance(moduleType) as IModuleControl;
|
||||
security = moduleobject.SecurityAccessLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -361,21 +361,20 @@
|
|||
|
||||
string panes = "";
|
||||
Type themetype = Type.GetType(page.ThemeType);
|
||||
var themeobject = Activator.CreateInstance(themetype);
|
||||
var themeobject = Activator.CreateInstance(themetype) as IThemeControl;
|
||||
if (themeobject != null)
|
||||
{
|
||||
panes = (string)themetype.GetProperty("Panes").GetValue(themeobject, null);
|
||||
var resources = (List<Resource>)themetype.GetProperty("Resources").GetValue(themeobject, null);
|
||||
page.Resources = ManagePageResources(page.Resources, resources);
|
||||
panes = themeobject.Panes;
|
||||
page.Resources = ManagePageResources(page.Resources, themeobject.Resources);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(page.LayoutType))
|
||||
{
|
||||
themetype = Type.GetType(page.LayoutType);
|
||||
themeobject = Activator.CreateInstance(themetype);
|
||||
if (themeobject != null)
|
||||
Type layouttype = Type.GetType(page.LayoutType);
|
||||
var layoutobject = Activator.CreateInstance(layouttype) as ILayoutControl;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
var resources = (List<Resource>)moduletype.GetProperty("Resources").GetValue(moduleobject, null);
|
||||
page.Resources = ManagePageResources(page.Resources, resources);
|
||||
module.ModuleType = "";
|
||||
}
|
||||
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
|
||||
if (module.ModuleId == moduleid && control != "")
|
||||
{
|
||||
module.SecurityAccessLevel = (SecurityAccessLevel)moduletype.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
module.ControlTitle = (string)moduletype.GetProperty("Title").GetValue(moduleobject);
|
||||
module.Actions = (string)moduletype.GetProperty("Actions").GetValue(moduleobject);
|
||||
module.UseAdminContainer = (bool)moduletype.GetProperty("UseAdminContainer").GetValue(moduleobject);
|
||||
module.SecurityAccessLevel = moduleobject.SecurityAccessLevel;
|
||||
module.ControlTitle = moduleobject.Title;
|
||||
module.Actions = moduleobject.Actions;
|
||||
module.UseAdminContainer = moduleobject.UseAdminContainer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(','))
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user