From 22c769ab98fd7c8cac9f975c0f57fa0b79a1be1a Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 29 Jan 2020 16:11:01 -0700 Subject: [PATCH] Updates to plugin dependency check logic --- PepperDashEssentials/ControlSystem.cs | 7 +-- .../PepperDashEssentialsBase/Global/Global.cs | 56 ++----------------- .../PepperDash_Essentials_Core.csproj | 1 - 3 files changed, 8 insertions(+), 56 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 17004617..af3754fd 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -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 diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index 174042de..39c89828 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -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; } - /// - /// Attempts to validate the JSON against the specified schema - /// - /// JSON to be validated - /// File name of schema to validate against - 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); - } - } - - - - /// - /// Event Handler callback for JSON validation - /// - /// - /// - 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 diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index caffdc5b..c6915164 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -152,7 +152,6 @@ -