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:
Shaun Walker
2019-08-30 22:27:49 -04:00
parent 838b48f91e
commit 8351ec2d71
12 changed files with 144 additions and 92 deletions

View File

@ -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;
}
}
}