Refactored IModule and ITheme interfaces for future compatibility scenarios. Added Permissions property to IModule interface to allow for explicit ordering and custom module permissions.
This commit is contained in:
@ -51,24 +51,26 @@ namespace Oqtane.Repository
|
||||
{
|
||||
/// determine if this module implements IModule
|
||||
Type moduletype = assembly.GetTypes()
|
||||
.Where(item => item.Namespace != null)
|
||||
.Where(item => item.Namespace.StartsWith(ModuleType))
|
||||
.Where(item => item.GetInterfaces().Contains(typeof(IModule)))
|
||||
.FirstOrDefault();
|
||||
.Where(item => item.Namespace != null)
|
||||
.Where(item => item.Namespace.StartsWith(ModuleType))
|
||||
.Where(item => item.GetInterfaces().Contains(typeof(IModule)))
|
||||
.FirstOrDefault();
|
||||
if (moduletype != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduletype);
|
||||
Dictionary<string, string> properties = (Dictionary<string, string>)moduletype.GetProperty("Properties").GetValue(moduleobject);
|
||||
moduledefinition = new ModuleDefinition
|
||||
{
|
||||
ModuleDefinitionName = QualifiedModuleType,
|
||||
Name = (string)moduletype.GetProperty("Name").GetValue(moduleobject),
|
||||
Description = (string)moduletype.GetProperty("Description").GetValue(moduleobject),
|
||||
Version = (string)moduletype.GetProperty("Version").GetValue(moduleobject),
|
||||
Owner = (string)moduletype.GetProperty("Owner").GetValue(moduleobject),
|
||||
Url = (string)moduletype.GetProperty("Url").GetValue(moduleobject),
|
||||
Contact = (string)moduletype.GetProperty("Contact").GetValue(moduleobject),
|
||||
License = (string)moduletype.GetProperty("License").GetValue(moduleobject),
|
||||
Dependencies = (string)moduletype.GetProperty("Dependencies").GetValue(moduleobject),
|
||||
Name = GetProperty(properties, "Name"),
|
||||
Description = GetProperty(properties, "Description"),
|
||||
Version = GetProperty(properties, "Version"),
|
||||
Owner = GetProperty(properties, "Owner"),
|
||||
Url = GetProperty(properties, "Url"),
|
||||
Contact = GetProperty(properties, "Contact"),
|
||||
License = GetProperty(properties, "License"),
|
||||
Dependencies = GetProperty(properties, "Dependencies"),
|
||||
Permissions = GetProperty(properties, "Permissions"),
|
||||
ControlTypeTemplate = ModuleType + ".{Control}" + ", " + typename[1],
|
||||
ControlTypeRoutes = "",
|
||||
AssemblyName = assembly.FullName.Split(",")[0]
|
||||
@ -87,6 +89,7 @@ namespace Oqtane.Repository
|
||||
Contact = "",
|
||||
License = "",
|
||||
Dependencies = "",
|
||||
Permissions = "",
|
||||
ControlTypeTemplate = ModuleType + ".{Control}" + ", " + typename[1],
|
||||
ControlTypeRoutes = "",
|
||||
AssemblyName = assembly.FullName.Split(",")[0]
|
||||
@ -118,5 +121,14 @@ namespace Oqtane.Repository
|
||||
return ModuleDefinitions;
|
||||
}
|
||||
|
||||
private string GetProperty(Dictionary<string, string> Properties, string Key)
|
||||
{
|
||||
string Value = "";
|
||||
if (Properties.ContainsKey(Key))
|
||||
{
|
||||
Value = Properties[Key];
|
||||
}
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,23 +49,24 @@ namespace Oqtane.Repository
|
||||
if (index == -1)
|
||||
{
|
||||
/// determine if this theme implements ITheme
|
||||
Type themeType = assembly.GetTypes()
|
||||
Type themetype = assembly.GetTypes()
|
||||
.Where(item => item.Namespace != null)
|
||||
.Where(item => item.Namespace.StartsWith(Namespace))
|
||||
.Where(item => item.GetInterfaces().Contains(typeof(ITheme))).FirstOrDefault();
|
||||
if (themeType != null)
|
||||
if (themetype != null)
|
||||
{
|
||||
var themeObject = Activator.CreateInstance(themeType);
|
||||
var themeobject = Activator.CreateInstance(themetype);
|
||||
Dictionary<string, string> properties = (Dictionary<string, string>)themetype.GetProperty("Properties").GetValue(themeobject);
|
||||
theme = new Theme
|
||||
{
|
||||
ThemeName = Namespace,
|
||||
Name = (string)themeType.GetProperty("Name").GetValue(themeObject),
|
||||
Version = (string)themeType.GetProperty("Version").GetValue(themeObject),
|
||||
Owner = (string)themeType.GetProperty("Owner").GetValue(themeObject),
|
||||
Url = (string)themeType.GetProperty("Url").GetValue(themeObject),
|
||||
Contact = (string)themeType.GetProperty("Contact").GetValue(themeObject),
|
||||
License = (string)themeType.GetProperty("License").GetValue(themeObject),
|
||||
Dependencies = (string)themeType.GetProperty("Dependencies").GetValue(themeObject),
|
||||
Name = GetProperty(properties, "Name"),
|
||||
Version = GetProperty(properties, "Version"),
|
||||
Owner = GetProperty(properties, "Owner"),
|
||||
Url = GetProperty(properties, "Url"),
|
||||
Contact = GetProperty(properties, "Contact"),
|
||||
License = GetProperty(properties, "License"),
|
||||
Dependencies = GetProperty(properties, "Dependencies"),
|
||||
ThemeControls = "",
|
||||
PaneLayouts = "",
|
||||
ContainerControls = "",
|
||||
@ -122,5 +123,15 @@ namespace Oqtane.Repository
|
||||
{
|
||||
return Themes;
|
||||
}
|
||||
|
||||
private string GetProperty(Dictionary<string, string> Properties, string Key)
|
||||
{
|
||||
string Value = "";
|
||||
if (Properties.ContainsKey(Key))
|
||||
{
|
||||
Value = Properties[Key];
|
||||
}
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user