mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-08 09:15:06 +00:00
Updates to plugin dependency check logic
This commit is contained in:
@@ -95,15 +95,13 @@ namespace PepperDash.Essentials
|
||||
|
||||
var dirSeparator = Global.DirectorySeparator;
|
||||
|
||||
var versionString = Global.GetAssemblyVersion();
|
||||
|
||||
string directoryPrefix;
|
||||
|
||||
directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory();
|
||||
|
||||
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows OS
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", versionString);
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", Global.GetAssemblyVersion());
|
||||
|
||||
// Check if User/ProgramX exists
|
||||
if (Directory.Exists(directoryPrefix + dirSeparator + "User"
|
||||
@@ -131,7 +129,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
else // Handles Linux OS (Virtual Control)
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", versionString);
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", Global.GetAssemblyVersion());
|
||||
|
||||
// Set path to User/
|
||||
filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator;
|
||||
@@ -282,6 +280,7 @@ namespace PepperDash.Essentials
|
||||
Debug.Console(2, "Load Plugin not found. {0} is not a plugin assembly", assy.Value.FullName);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharp.CrestronDataStore;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Essentials.Core.Http;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.License;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Schema;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
@@ -100,56 +104,6 @@ namespace PepperDash.Essentials.Core
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to validate the JSON against the specified schema
|
||||
/// </summary>
|
||||
/// <param name="json">JSON to be validated</param>
|
||||
/// <param name="schemaFileName">File name of schema to validate against</param>
|
||||
public static void ValidateSchema(string json, string schemaFileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Validating Config against Schema...");
|
||||
JObject config = JObject.Parse(json);
|
||||
|
||||
Debug.Console(2, "Config: \n{0}", json);
|
||||
|
||||
using (StreamReader fileStream = new StreamReader(schemaFileName))
|
||||
{
|
||||
JsonSchemaResolver resolver = new JsonSchemaResolver();
|
||||
|
||||
JsonSchema schema = JsonSchema.Parse(fileStream.ReadToEnd(), resolver);
|
||||
|
||||
|
||||
Debug.Console(2, "Schema: \n{0}", schema.ToString());
|
||||
|
||||
if (config.IsValid(schema))
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Configuration successfully Validated Against Schema");
|
||||
else
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Validation Errors Found in Configuration:");
|
||||
config.Validate(schema, Json_ValidationEventHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, "Error in ValidateSchema: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler callback for JSON validation
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
public static void Json_ValidationEventHandler(object sender, ValidationEventArgs args)
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "JSON Validation error at line {0} position {1}: {2}", args.Exception.LineNumber, args.Exception.LinePosition, args.Message);
|
||||
}
|
||||
|
||||
static Global()
|
||||
{
|
||||
// Fire up CrestronDataStoreStatic
|
||||
|
||||
@@ -152,7 +152,6 @@
|
||||
<Compile Include="Monitoring\SystemMonitorController.cs" />
|
||||
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
|
||||
<Compile Include="Microphone Privacy\MicrophonePrivacyControllerConfig.cs" />
|
||||
<Compile Include="Plugins\IEssentialsPlugin.cs" />
|
||||
<Compile Include="Ramps and Increments\ActionIncrementer.cs" />
|
||||
<Compile Include="Comm and IR\CommFactory.cs" />
|
||||
<Compile Include="Comm and IR\CommunicationExtras.cs" />
|
||||
|
||||
Reference in New Issue
Block a user