From 494b8b09e1ec6f9291173046efeb22cdfb1e54d0 Mon Sep 17 00:00:00 2001 From: Heath Volmer Date: Fri, 11 May 2018 15:05:22 -0600 Subject: [PATCH] 1.0.5 fix for array lookups that fail stepping on index 0. Reduced debugging output --- .../JsonToSimpl/JsonToSimplArrayLookupChild.cs | 8 +++++--- .../JsonToSimpl/JsonToSimplChildObjectBase.cs | 18 ++++++++++++++++-- .../JsonToSimpl/JsonToSimplFixedPathObject.cs | 1 + .../Pepperdash Core/Properties/AssemblyInfo.cs | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplArrayLookupChild.cs b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplArrayLookupChild.cs index 6b3d1b1..d149bbc 100644 --- a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplArrayLookupChild.cs +++ b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplArrayLookupChild.cs @@ -67,23 +67,25 @@ namespace PepperDash.Core.JsonToSimpl }); if (item == null) { - Debug.Console(0, "Child[{0}] Array '{1}' '{2}={3}' not found: ", Key, + Debug.Console(1, "Child[{0}] Array '{1}' '{2}={3}' not found: ", Key, PathPrefix, SearchPropertyName, SearchPropertyValue); + this.LinkedToObject = false; return false; } + this.LinkedToObject = true; ArrayIndex = array.IndexOf(item); Debug.Console(1, "Child[{0}] Found array match at index {1}", Key, ArrayIndex); return true; } catch (Exception e) { - Debug.Console(0, "Child[{0}] Array '{1}' lookup error: '{2}={3}'\r{4}", Key, + Debug.Console(1, "Child[{0}] Array '{1}' lookup error: '{2}={3}'\r{4}", Key, PathPrefix, SearchPropertyName, SearchPropertyValue, e); } } else - Debug.Console(0, "Child[{0}] Path '{1}' is not an array", Key, PathPrefix); + Debug.Console(1, "Child[{0}] Path '{1}' is not an array", Key, PathPrefix); return false; } diff --git a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplChildObjectBase.cs b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplChildObjectBase.cs index bd7979c..caf5ad4 100644 --- a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplChildObjectBase.cs +++ b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplChildObjectBase.cs @@ -35,6 +35,8 @@ namespace PepperDash.Core.JsonToSimpl /// public string PathSuffix { get; protected set; } + public bool LinkedToObject { get; protected set; } + protected JsonToSimplMaster Master; // The sent-in JPaths for the various types @@ -101,6 +103,12 @@ namespace PepperDash.Core.JsonToSimpl /// public virtual void ProcessAll() { + if (!LinkedToObject) + { + Debug.Console(1, this, "Not linked to object in file. Skipping"); + return; + } + if (SetAllPathsDelegate == null) { Debug.Console(1, this, "No SetAllPathsDelegate set. Ignoring ProcessAll"); @@ -166,7 +174,7 @@ namespace PepperDash.Core.JsonToSimpl response = ""; if (Master == null) { - Debug.Console(0, "JSONChild[{0}] cannot process without Master attached", Key); + Debug.Console(1, "JSONChild[{0}] cannot process without Master attached", Key); return false; } @@ -213,6 +221,12 @@ namespace PepperDash.Core.JsonToSimpl /// public void UpdateInputsForMaster() { + if (!LinkedToObject) + { + Debug.Console(1, this, "Not linked to object in file. Skipping"); + return; + } + if (SetAllPathsDelegate == null) { Debug.Console(1, this, "No SetAllPathsDelegate set. Ignoring UpdateInputsForMaster"); @@ -260,7 +274,7 @@ namespace PepperDash.Core.JsonToSimpl } catch (Exception e) { - Debug.Console(0, "Child[{0}] Failed setting value for path '{1}'\r{2}", Key, path, e); + Debug.Console(1, "Child[{0}] Failed setting value for path '{1}'\r{2}", Key, path, e); } } diff --git a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFixedPathObject.cs b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFixedPathObject.cs index d674d03..01fc2ba 100644 --- a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFixedPathObject.cs +++ b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFixedPathObject.cs @@ -15,6 +15,7 @@ namespace PepperDash.Core.JsonToSimpl { public JsonToSimplFixedPathObject() { + this.LinkedToObject = true; } } } \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs b/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs index 5be34b2..1ffacd6 100644 --- a/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs +++ b/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Pepperdash_Core")] [assembly: AssemblyCopyright("Copyright © PepperDash 2016")] -[assembly: AssemblyVersion("1.0.4.*")] +[assembly: AssemblyVersion("1.0.5.*")]