mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-13 20:47:04 +00:00
New device loading methodology working via reflection
This commit is contained in:
parent
911bd8daba
commit
a93ded8c79
12 changed files with 121 additions and 268 deletions
|
|
@ -86,47 +86,6 @@ namespace PepperDash.Essentials
|
|||
GoWithLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates each of the device factories to load their device types
|
||||
/// </summary>
|
||||
void LoadDeviceTypesFromFactories()
|
||||
{
|
||||
PluginLoader.AddProgramAssemblies();
|
||||
|
||||
|
||||
foreach (var assembly in PluginLoader.LoadedAssemblies)
|
||||
{
|
||||
if (!assembly.Name.Contains("Essentials"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
var assy = assembly.Assembly;
|
||||
var types = assy.GetTypes();
|
||||
|
||||
if (types != null)
|
||||
{
|
||||
foreach (var type in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (typeof(IDeviceFactory).IsAssignableFrom(type))
|
||||
{
|
||||
var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
|
||||
factory.LoadTypeFactories();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load DeviceFactory: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the program is running on a processor (appliance) or server (VC-4).
|
||||
///
|
||||
|
|
@ -202,10 +161,15 @@ namespace PepperDash.Essentials
|
|||
public void GoWithLoad()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
Debug.SetDoNotLoadOnNextBoot(false);
|
||||
|
||||
LoadDeviceTypesFromFactories();
|
||||
PluginLoader.AddProgramAssemblies();
|
||||
|
||||
new Core.DeviceFactory();
|
||||
new Devices.Common.DeviceFactory();
|
||||
new DM.DeviceFactory();
|
||||
new DeviceFactory();
|
||||
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue