feat: Replaces Crestron.SimplSharp.Reflection with System.Reflextion and updates the way essentials plugin versions are stored and retrieved

This commit is contained in:
Neil Dorin
2024-05-23 14:11:42 -06:00
parent 621d848418
commit 0a2aaa693f
24 changed files with 100 additions and 89 deletions

View File

@@ -3,7 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication; using Crestron.SimplSharpPro.EthernetCommunication;
@@ -168,7 +168,7 @@ namespace PepperDash.Essentials.Core.Bridges
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Device: '{0}'", device.Key); Debug.LogMessage(LogEventLevel.Debug, this, "Linking Device: '{0}'", device.Key);
if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetType()))
{ {
Debug.LogMessage(LogEventLevel.Information, this, Debug.LogMessage(LogEventLevel.Information, this,
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", "{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",

View File

@@ -1,18 +1,16 @@
using Crestron.SimplSharp;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {
/// <summary> /// <summary>
/// Represents the info section of a Config file /// Represents the info section of a Config file
/// </summary> /// </summary>
public class InfoConfig public class InfoConfig
{ {
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }

View File

@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
@@ -63,7 +63,7 @@ namespace PepperDash.Essentials.Core
action.Params = new object[0]; action.Params = new object[0];
} }
CType t = obj.GetType(); Type t = obj.GetType();
try try
{ {
var methods = t.GetMethods().Where(m => m.Name == action.MethodName).ToList(); var methods = t.GetMethods().Where(m => m.Name == action.MethodName).ToList();
@@ -121,7 +121,7 @@ namespace PepperDash.Essentials.Core
if (obj == null) if (obj == null)
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
CType t = obj.GetType(); Type t = obj.GetType();
// get the properties and set them into a new collection of NameType wrappers // get the properties and set them into a new collection of NameType wrappers
var props = t.GetProperties().Select(p => new PropertyNameType(p, obj)); var props = t.GetProperties().Select(p => new PropertyNameType(p, obj));
return JsonConvert.SerializeObject(props, Formatting.Indented); return JsonConvert.SerializeObject(props, Formatting.Indented);
@@ -139,7 +139,7 @@ namespace PepperDash.Essentials.Core
if(dev == null) if(dev == null)
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
object prop = dev.GetType().GetCType().GetProperty(propertyName).GetValue(dev, null); object prop = dev.GetType().GetType().GetProperty(propertyName).GetValue(dev, null);
// var prop = t.GetProperty(propertyName); // var prop = t.GetProperty(propertyName);
if (prop != null) if (prop != null)
@@ -165,7 +165,7 @@ namespace PepperDash.Essentials.Core
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
// Package up method names using helper objects // Package up method names using helper objects
CType t = obj.GetType(); Type t = obj.GetType();
var methods = t.GetMethods() var methods = t.GetMethods()
.Where(m => !m.IsSpecialName) .Where(m => !m.IsSpecialName)
.Select(p => new MethodNameParams(p)); .Select(p => new MethodNameParams(p));
@@ -179,7 +179,7 @@ namespace PepperDash.Essentials.Core
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
// Package up method names using helper objects // Package up method names using helper objects
CType t = obj.GetType(); Type t = obj.GetType();
var methods = t.GetMethods() var methods = t.GetMethods()
.Where(m => !m.IsSpecialName) .Where(m => !m.IsSpecialName)
.Where(m => m.GetCustomAttributes(typeof(ApiAttribute), true).Any()) .Where(m => m.GetCustomAttributes(typeof(ApiAttribute), true).Any())
@@ -226,7 +226,7 @@ namespace PepperDash.Essentials.Core
Debug.LogMessage(LogEventLevel.Information, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr); Debug.LogMessage(LogEventLevel.Information, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr);
} }
CType oType = obj.GetType(); Type oType = obj.GetType();
var prop = oType.GetProperty(objName); var prop = oType.GetProperty(objName);
if (prop == null) if (prop == null)
{ {
@@ -256,7 +256,7 @@ namespace PepperDash.Essentials.Core
obj = indexedPropInfo.GetValue(collection, new object[] { properParam }); obj = indexedPropInfo.GetValue(collection, new object[] { properParam });
} }
// if the index is bad, catch it here. // if the index is bad, catch it here.
catch (Crestron.SimplSharp.Reflection.TargetInvocationException e) catch (TargetInvocationException e)
{ {
if (e.InnerException is ArgumentOutOfRangeException) if (e.InnerException is ArgumentOutOfRangeException)
Debug.LogMessage(LogEventLevel.Information, " Index Out of range"); Debug.LogMessage(LogEventLevel.Information, " Index Out of range");
@@ -287,7 +287,7 @@ namespace PepperDash.Essentials.Core
//if (obj == null) //if (obj == null)
// return "{\"error\":\"No object found\"}"; // return "{\"error\":\"No object found\"}";
//CType t = obj.GetType(); //Type t = obj.GetType();
//// get the properties and set them into a new collection of NameType wrappers //// get the properties and set them into a new collection of NameType wrappers
@@ -365,7 +365,7 @@ namespace PepperDash.Essentials.Core
} }
[AttributeUsage(AttributeTargets.All)] [AttributeUsage(AttributeTargets.All)]
public class ApiAttribute : CAttribute public class ApiAttribute : Attribute
{ {
} }

View File

@@ -166,7 +166,7 @@ namespace PepperDash.Essentials.Core
// var dev = GetDeviceForKey(devKey); // var dev = GetDeviceForKey(devKey);
// if(dev != null) // if(dev != null)
// { // {
// var type = dev.GetType().GetCType(); // var type = dev.GetType().GetType();
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance); // var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
// var sb = new StringBuilder(); // var sb = new StringBuilder();
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length)); // sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;

View File

@@ -1,7 +1,5 @@
using System.Collections.Generic; using System;
using System.Linq; using System.Linq;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core; using PepperDash.Core;
using Serilog.Events; using Serilog.Events;
@@ -23,7 +21,7 @@ namespace PepperDash.Essentials.Core
{ {
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates) public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{ {
CType t = source.GetType(); Type t = source.GetType();
// get the properties and set them into a new collection of NameType wrappers // get the properties and set them into a new collection of NameType wrappers
var props = t.GetProperties().Select(p => new PropertyNameType(p, t)); var props = t.GetProperties().Select(p => new PropertyNameType(p, t));

View File

@@ -1,7 +1,7 @@
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
@@ -14,13 +14,13 @@ namespace PepperDash.Essentials.Core
{ {
public class DeviceFactoryWrapper public class DeviceFactoryWrapper
{ {
public CType CType { get; set; } public Type Type { get; set; }
public string Description { get; set; } public string Description { get; set; }
public Func<DeviceConfig, IKeyed> FactoryMethod { get; set; } public Func<DeviceConfig, IKeyed> FactoryMethod { get; set; }
public DeviceFactoryWrapper() public DeviceFactoryWrapper()
{ {
CType = null; Type = null;
Description = "Not Available"; Description = "Not Available";
} }
} }
@@ -40,7 +40,7 @@ namespace PepperDash.Essentials.Core
{ {
try try
{ {
var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); var factory = (IDeviceFactory)Activator.CreateInstance(type);
factory.LoadTypeFactories(); factory.LoadTypeFactories();
} }
catch (Exception e) catch (Exception e)
@@ -69,7 +69,7 @@ namespace PepperDash.Essentials.Core
DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method}); DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method});
} }
public static void AddFactoryForType(string typeName, string description, CType cType, Func<DeviceConfig, IKeyed> method) public static void AddFactoryForType(string typeName, string description, Type Type, Func<DeviceConfig, IKeyed> method)
{ {
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); //Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
@@ -79,7 +79,7 @@ namespace PepperDash.Essentials.Core
return; return;
} }
var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method }; var wrapper = new DeviceFactoryWrapper() { Type = Type, Description = description, FactoryMethod = method };
DeviceFactory.FactoryMethods.Add(typeName, wrapper); DeviceFactory.FactoryMethods.Add(typeName, wrapper);
} }
@@ -180,17 +180,17 @@ namespace PepperDash.Essentials.Core
foreach (var type in types.OrderBy(t => t.Key)) foreach (var type in types.OrderBy(t => t.Key))
{ {
var description = type.Value.Description; var description = type.Value.Description;
var cType = "Not Specified by Plugin"; var Type = "Not Specified by Plugin";
if (type.Value.CType != null) if (type.Value.Type != null)
{ {
cType = type.Value.CType.FullName; Type = type.Value.Type.FullName;
} }
CrestronConsole.ConsoleCommandResponse( CrestronConsole.ConsoleCommandResponse(
@"Type: '{0}' @"Type: '{0}'
CType: '{1}' Type: '{1}'
Description: {2}{3}", type.Key, cType, description, CrestronEnvironment.NewLine); Description: {2}{3}", type.Key, Type, description, CrestronEnvironment.NewLine);
} }
} }

View File

@@ -1,14 +1,4 @@
using System; namespace PepperDash.Essentials.Core
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core
{ {
/// <summary> /// <summary>
/// Defines a class that is capable of loading device types /// Defines a class that is capable of loading device types

View File

@@ -1,5 +1,5 @@
using Crestron.SimplSharp.Reflection; using System.Reflection;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using Serilog.Events; using Serilog.Events;
@@ -25,7 +25,7 @@ namespace PepperDash.Essentials.Core
{ {
try try
{ {
var factory = (IProcessorExtensionDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(extension); var factory = (IProcessorExtensionDeviceFactory)Activator.CreateInstance(extension);
factory.LoadFactories(); factory.LoadFactories();
} }
catch( Exception e ) catch( Exception e )
@@ -55,7 +55,7 @@ namespace PepperDash.Essentials.Core
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method }); ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method });
} }
public static void AddFactoryForType(string extensionName, string description, CType cType, Func<DeviceConfig, IKeyed> method) public static void AddFactoryForType(string extensionName, string description, Type Type, Func<DeviceConfig, IKeyed> method)
{ {
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); //Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
@@ -65,7 +65,7 @@ namespace PepperDash.Essentials.Core
return; return;
} }
var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method }; var wrapper = new DeviceFactoryWrapper() { Type = Type, Description = description, FactoryMethod = method };
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, wrapper); ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, wrapper);
} }

View File

@@ -137,6 +137,7 @@ namespace PepperDash.Essentials.Core
public static void SetFilePathPrefix(string prefix) public static void SetFilePathPrefix(string prefix)
{ {
FilePathPrefix = prefix; FilePathPrefix = prefix;
Debug.LogMessage(LogEventLevel.Information, "File Path Prefix set to '{0}'", FilePathPrefix);
} }
static string _AssemblyVersion; static string _AssemblyVersion;

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharp; using Crestron.SimplSharp;
@@ -109,7 +109,7 @@ namespace PepperDash.Essentials.Core
protected void AddJoins(Type type) protected void AddJoins(Type type)
{ {
var fields = var fields =
type.GetCType() type.GetType()
.GetFields(BindingFlags.Public | BindingFlags.Instance) .GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(f => f.IsDefined(typeof (JoinNameAttribute), true)); .Where(f => f.IsDefined(typeof (JoinNameAttribute), true));
@@ -501,7 +501,7 @@ namespace PepperDash.Essentials.Core
public string GetNameAttribute(MemberInfo memberInfo) public string GetNameAttribute(MemberInfo memberInfo)
{ {
var name = string.Empty; var name = string.Empty;
var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute)); var attribute = (JoinNameAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));
if (attribute == null) return name; if (attribute == null) return name;
@@ -514,7 +514,7 @@ namespace PepperDash.Essentials.Core
[AttributeUsage(AttributeTargets.All)] [AttributeUsage(AttributeTargets.All)]
public class JoinNameAttribute : CAttribute public class JoinNameAttribute : Attribute
{ {
private string _Name; private string _Name;

View File

@@ -11,6 +11,9 @@
<RootNamespace>PepperDash.Essentials.Core</RootNamespace> <RootNamespace>PepperDash.Essentials.Core</RootNamespace>
<Title>PepperDash Essentials Core</Title> <Title>PepperDash Essentials Core</Title>
<PackageId>PepperDash.Essentials.Core</PackageId> <PackageId>PepperDash.Essentials.Core</PackageId>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>2.0.0-local</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType> <DebugType>full</DebugType>
@@ -23,7 +26,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" /> <PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-419" /> <PackageReference Include="PepperDashCore" Version="2.0.0-alpha-420" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" /> <None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />

View File

@@ -1,14 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using Serilog.Events; using Serilog.Events;
using Newtonsoft.Json;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
@@ -27,24 +27,29 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
static List<LoadedAssembly> LoadedPluginFolderAssemblies; static List<LoadedAssembly> LoadedPluginFolderAssemblies;
public static LoadedAssembly EssentialsAssembly { get; private set; }
public static List<LoadedAssembly> EssentialsPluginAssemblies { get; private set; }
/// <summary> /// <summary>
/// The directory to look in for .cplz plugin packages /// The directory to look in for .cplz plugin packages
/// </summary> /// </summary>
static string _pluginDirectory = Global.FilePathPrefix + "plugins"; static string _pluginDirectory => Global.FilePathPrefix + "plugins";
/// <summary> /// <summary>
/// The directory where plugins will be moved to and loaded from /// The directory where plugins will be moved to and loaded from
/// </summary> /// </summary>
static string _loadedPluginsDirectoryPath = _pluginDirectory + Global.DirectorySeparator + "loadedAssemblies"; static string _loadedPluginsDirectoryPath => _pluginDirectory + Global.DirectorySeparator + "loadedAssemblies";
// The temp directory where .cplz archives will be unzipped to // The temp directory where .cplz archives will be unzipped to
static string _tempDirectory = _pluginDirectory + Global.DirectorySeparator + "temp"; static string _tempDirectory => _pluginDirectory + Global.DirectorySeparator + "temp";
static PluginLoader() static PluginLoader()
{ {
LoadedAssemblies = new List<LoadedAssembly>(); LoadedAssemblies = new List<LoadedAssembly>();
LoadedPluginFolderAssemblies = new List<LoadedAssembly>(); LoadedPluginFolderAssemblies = new List<LoadedAssembly>();
EssentialsPluginAssemblies = new List<LoadedAssembly>();
} }
/// <summary> /// <summary>
@@ -69,6 +74,7 @@ namespace PepperDash.Essentials
case ("PepperDashEssentials.dll"): case ("PepperDashEssentials.dll"):
{ {
version = Global.AssemblyVersion; version = Global.AssemblyVersion;
EssentialsAssembly = new LoadedAssembly(fi.Name, version, assembly);
break; break;
} }
case ("PepperDash_Essentials_Core.dll"): case ("PepperDash_Essentials_Core.dll"):
@@ -144,7 +150,7 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
/// <param name="assembly"></param> /// <param name="assembly"></param>
/// <returns></returns> /// <returns></returns>
static string GetAssemblyVersion(Assembly assembly) public static string GetAssemblyVersion(Assembly assembly)
{ {
var ver = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); var ver = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
if (ver != null && ver.Length > 0) if (ver != null && ver.Length > 0)
@@ -190,12 +196,18 @@ namespace PepperDash.Essentials
/// <param name="command"></param> /// <param name="command"></param>
public static void ReportAssemblyVersions(string command) public static void ReportAssemblyVersions(string command)
{ {
CrestronConsole.ConsoleCommandResponse("Essentials Version: {0}" + CrestronEnvironment.NewLine, Global.AssemblyVersion);
CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:" + CrestronEnvironment.NewLine); CrestronConsole.ConsoleCommandResponse("Essentials Plugin Versions:" + CrestronEnvironment.NewLine);
foreach (var assembly in LoadedAssemblies) foreach (var assembly in EssentialsPluginAssemblies)
{ {
CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version); CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version);
} }
//CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:" + CrestronEnvironment.NewLine);
//foreach (var assembly in LoadedAssemblies)
//{
// CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version);
//}
} }
/// <summary> /// <summary>
/// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder /// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder
@@ -354,7 +366,7 @@ namespace PepperDash.Essentials
try try
{ {
var assy = loadedAssembly.Assembly; var assy = loadedAssembly.Assembly;
CType[] types = {}; Type[] types = {};
try try
{ {
types = assy.GetTypes(); types = assy.GetTypes();
@@ -375,7 +387,7 @@ namespace PepperDash.Essentials
if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract) if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract)
{ {
var plugin = var plugin =
(IPluginDeviceFactory) Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); (IPluginDeviceFactory)Activator.CreateInstance(type);
LoadCustomPlugin(plugin, loadedAssembly); LoadCustomPlugin(plugin, loadedAssembly);
} }
} }
@@ -432,6 +444,9 @@ namespace PepperDash.Essentials
Debug.LogMessage(LogEventLevel.Information, "Loading plugin: {0}", loadedAssembly.Name); Debug.LogMessage(LogEventLevel.Information, "Loading plugin: {0}", loadedAssembly.Name);
plugin.LoadTypeFactories(); plugin.LoadTypeFactories();
if(!EssentialsPluginAssemblies.Contains(loadedAssembly))
EssentialsPluginAssemblies.Add(loadedAssembly);
} }
/// <summary> /// <summary>
@@ -439,7 +454,7 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
/// <param name="type"></param> /// <param name="type"></param>
/// <param name="loadPlugin"></param> /// <param name="loadPlugin"></param>
static void LoadCustomLegacyPlugin(CType type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly) static void LoadCustomLegacyPlugin(Type type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly)
{ {
Debug.LogMessage(LogEventLevel.Verbose, "LoadPlugin method found in {0}", type.Name); Debug.LogMessage(LogEventLevel.Verbose, "LoadPlugin method found in {0}", type.Name);
@@ -486,6 +501,8 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public static void LoadPlugins() public static void LoadPlugins()
{ {
Debug.LogMessage(LogEventLevel.Information, "Attempting to Load Plugins from {_pluginDirectory}", _pluginDirectory);
if (Directory.Exists(_pluginDirectory)) if (Directory.Exists(_pluginDirectory))
{ {
Debug.LogMessage(LogEventLevel.Information, "Plugins directory found, checking for plugins"); Debug.LogMessage(LogEventLevel.Information, "Plugins directory found, checking for plugins");
@@ -514,8 +531,11 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public class LoadedAssembly public class LoadedAssembly
{ {
[JsonProperty("name")]
public string Name { get; private set; } public string Name { get; private set; }
[JsonProperty("version")]
public string Version { get; private set; } public string Version { get; private set; }
[JsonIgnore]
public Assembly Assembly { get; private set; } public Assembly Assembly { get; private set; }
public LoadedAssembly(string name, string version, Assembly assembly) public LoadedAssembly(string name, string version, Assembly assembly)

View File

@@ -80,7 +80,7 @@ namespace PepperDash.Essentials.Core.Web
{ {
Type = device.Key, Type = device.Key,
Description = device.Value.Description, Description = device.Value.Description,
CType = device.Value.CType == null ? "---": device.Value.CType.ToString() CType = device.Value.Type == null ? "---": device.Value.Type.ToString()
}; };
} }
} }

View File

@@ -6,7 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;

View File

@@ -12,7 +12,7 @@ using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.Codec;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Serilog.Events; using Serilog.Events;

View File

@@ -2,7 +2,7 @@
using System; using System;
using System.Linq; using System.Linq;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using Serilog.Events; using Serilog.Events;
@@ -25,7 +25,7 @@ namespace PepperDash.Essentials.Devices.Common
{ {
try try
{ {
var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); var factory = (IDeviceFactory)Activator.CreateInstance(type);
factory.LoadTypeFactories(); factory.LoadTypeFactories();
} }
catch (Exception e) catch (Exception e)

View File

@@ -12,6 +12,9 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>PepperDash Essentials Devices Common</Title> <Title>PepperDash Essentials Devices Common</Title>
<PackageId>PepperDash.Essentials.Devices.Common</PackageId> <PackageId>PepperDash.Essentials.Devices.Common</PackageId>
<Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType> <DebugType>full</DebugType>
@@ -27,6 +30,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" /> <PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-419" /> <PackageReference Include="PepperDashCore" Version="2.0.0-alpha-420" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -42,7 +42,7 @@ namespace PepperDash.Essentials.Devices.Common
public void PrintExpectedIrCommands() public void PrintExpectedIrCommands()
{ {
var cmds = typeof (AppleTvIrCommands).GetCType().GetFields(BindingFlags.Public | BindingFlags.Static); var cmds = typeof (AppleTvIrCommands).GetType().GetFields(BindingFlags.Public | BindingFlags.Static);
foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType<string>()) foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType<string>())
{ {

View File

@@ -1214,7 +1214,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
var entryIndex = counterIndex; var entryIndex = counterIndex;
Debug.LogMessage(LogEventLevel.Verbose, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}", Debug.LogMessage(LogEventLevel.Verbose, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}",
entry.Name, entry.FolderId, entryIndex, entry.GetType().GetCType().FullName, entry.ParentFolderId); entry.Name, entry.FolderId, entryIndex, entry.GetType().GetType().FullName, entry.ParentFolderId);
if (entry is DirectoryFolder) if (entry is DirectoryFolder)
{ {

View File

@@ -1,7 +1,7 @@
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.CrestronThread; using Crestron.SimplSharpPro.CrestronThread;
using Crestron.SimplSharpPro.Diagnostics; using Crestron.SimplSharpPro.Diagnostics;
@@ -172,11 +172,7 @@ namespace PepperDash.Essentials
directoryPrefix = Directory.GetApplicationRootDirectory(); directoryPrefix = Directory.GetApplicationRootDirectory();
var fullVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Global.SetAssemblyVersion(PluginLoader.GetAssemblyVersion(Assembly.GetExecutingAssembly()));
Global.SetAssemblyVersion(fullVersion);
//Global.SetAssemblyVersion(fullVersionAtt.InformationalVersion);
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS
{ {

View File

@@ -61,7 +61,7 @@
"supportedSystemTypes": [ "supportedSystemTypes": [
"hudType", "hudType",
"presType", "presType",
"vtcType", "vtType",
"custom" "custom"
], ],
"type": "rmc3", "type": "rmc3",

View File

@@ -6,7 +6,7 @@ using System.Linq;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharp.Reflection; using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -35,7 +35,7 @@ namespace PepperDash.Essentials
{ {
try try
{ {
var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); var factory = (IDeviceFactory)Activator.CreateInstance(type);
factory.LoadTypeFactories(); factory.LoadTypeFactories();
} }
catch (Exception e) catch (Exception e)

View File

@@ -11,7 +11,9 @@
<OutputPath>bin\$(Configuration)\</OutputPath> <OutputPath>bin\$(Configuration)\</OutputPath>
<Title>PepperDash Essentials</Title> <Title>PepperDash Essentials</Title>
<PackageId>PepperDashEssentials</PackageId> <PackageId>PepperDashEssentials</PackageId>
<AssemblyInformationalVersion>$(Version)</AssemblyInformationalVersion> <Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType> <DebugType>full</DebugType>
@@ -47,7 +49,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.20.42" /> <PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-419" /> <PackageReference Include="PepperDashCore" Version="2.0.0-alpha-420" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" /> <ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />