diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs index a72bd282..a3ca94f3 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -131,4 +131,15 @@ namespace PepperDash.Essentials.Core /// public string MinimumEssentialsFrameworkVersion { get; protected set; } } + + public abstract class EssentialsPluginDevelopmentDeviceFactory : EssentialsDeviceFactory, IPluginDevelopmentDeviceFactory where T : EssentialsDevice + { + /// + /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") + /// + public string MinimumEssentialsFrameworkVersion { get; protected set; } + + public List DevelopmentEssentialsFrameworkVersions { get; protected set; } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index 9d792437..cba66780 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Text.RegularExpressions; using System.Globalization; using Crestron.SimplSharp; @@ -122,6 +123,32 @@ namespace PepperDash.Essentials.Core AssemblyVersion = assemblyVersion; } + public static bool IsRunningDevelopmentVersion(List developmentVersions, string minimumVersion) + { + if (developmentVersions == null) + { + Debug.Console(0, + "Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version"); + return IsRunningMinimumVersionOrHigher(minimumVersion); + } + + Debug.Console(2, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions); + + var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion); + + if (String.IsNullOrEmpty(versionMatch)) + { + Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load."); + return false; + } + + Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion); + return IsRunningMinimumVersionOrHigher(minimumVersion); + + + + } + /// /// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true. /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs index ff979599..ec823007 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using PepperDash.Core; @@ -15,5 +16,10 @@ namespace PepperDash.Essentials.Core } + public interface IPluginDevelopmentDeviceFactory : IPluginDeviceFactory + { + List DevelopmentEssentialsFrameworkVersions { get; } + } +} + -} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs index 445db6bf..9da843b8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs @@ -425,9 +425,11 @@ namespace PepperDash.Essentials /// static void LoadCustomPlugin(IPluginDeviceFactory plugin, LoadedAssembly loadedAssembly) { - var explicitPlugin = plugin as IPluginDeviceFactoryExplicit; + var developmentPlugin = plugin as IPluginDevelopmentDeviceFactory; - var passed = explicitPlugin != null ? Global.IsRunningExplicitVersion(explicitPlugin.ExplicitEssentialsFrameworkVersions) : Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion); + var passed = developmentPlugin != null ? Global.IsRunningDevelopmentVersion + (developmentPlugin.DevelopmentEssentialsFrameworkVersions, developmentPlugin.MinimumEssentialsFrameworkVersion) + : Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion); if (!passed) {