merge: feature/VideoCodec-Phonebook-Clear

This commit is contained in:
Trevor Payne
2022-08-17 13:18:25 -05:00
parent cf3563d6b6
commit c2deaf9534
4 changed files with 49 additions and 3 deletions

View File

@@ -131,4 +131,15 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public string MinimumEssentialsFrameworkVersion { get; protected set; } public string MinimumEssentialsFrameworkVersion { get; protected set; }
} }
public abstract class EssentialsPluginDevelopmentDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDevelopmentDeviceFactory where T : EssentialsDevice
{
/// <summary>
/// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33")
/// </summary>
public string MinimumEssentialsFrameworkVersion { get; protected set; }
public List<string> DevelopmentEssentialsFrameworkVersions { get; protected set; }
}
} }

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Globalization; using System.Globalization;
using Crestron.SimplSharp; using Crestron.SimplSharp;
@@ -120,6 +121,32 @@ namespace PepperDash.Essentials.Core
public static void SetAssemblyVersion(string assemblyVersion) public static void SetAssemblyVersion(string assemblyVersion)
{ {
AssemblyVersion = assemblyVersion; AssemblyVersion = assemblyVersion;
}
public static bool IsRunningDevelopmentVersion(List<string> 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);
} }
/// <summary> /// <summary>

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using PepperDash.Core; using PepperDash.Core;
@@ -15,5 +16,10 @@ namespace PepperDash.Essentials.Core
} }
public interface IPluginDevelopmentDeviceFactory : IPluginDeviceFactory
{
List<string> DevelopmentEssentialsFrameworkVersions { get; }
} }
}

View File

@@ -425,9 +425,11 @@ namespace PepperDash.Essentials
/// <param name="loadedAssembly"></param> /// <param name="loadedAssembly"></param>
static void LoadCustomPlugin(IPluginDeviceFactory plugin, LoadedAssembly loadedAssembly) 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) if (!passed)
{ {