Adds method SetPathPrefix to JSON SiMPL Child Onject

Reinstated the  default from proces%type%Path mehods. If no path no change propegates.
This commit is contained in:
JTA
2017-07-30 14:34:51 -04:00
parent 5e7c7771a3
commit 632b2ea3b4
6 changed files with 15 additions and 12 deletions

Binary file not shown.

View File

@@ -62,6 +62,9 @@ namespace PepperDash.Core.JsonToSimpl
Debug.Console(1, "JSON Child [{0}] cannot link to master {1}", key, masterUniqueId); Debug.Console(1, "JSON Child [{0}] cannot link to master {1}", key, masterUniqueId);
} }
public void SetPathPrefix(string pathPrefix) {
PathPrefix = pathPrefix;
}
/// <summary> /// <summary>
/// Set the JPath to evaluate for a given bool out index. /// Set the JPath to evaluate for a given bool out index.
/// </summary> /// </summary>
@@ -121,23 +124,21 @@ namespace PepperDash.Core.JsonToSimpl
if (Process(BoolPaths[index], out response)) if (Process(BoolPaths[index], out response))
OnBoolChange(response.Equals("true", StringComparison.OrdinalIgnoreCase), OnBoolChange(response.Equals("true", StringComparison.OrdinalIgnoreCase),
index, JsonToSimplConstants.BoolValueChange); index, JsonToSimplConstants.BoolValueChange);
else else { }
OnBoolChange(false, index, JsonToSimplConstants.BoolValueChange); // OnBoolChange(false, index, JsonToSimplConstants.BoolValueChange);
} }
// Processes the path to a ushort, converting to ushort if able, firing off UshrtChange event // Processes the path to a ushort, converting to ushort if able, firing off UshrtChange event
void ProcessUshortPath(ushort index) void ProcessUshortPath(ushort index)
{ {
string response; string response;
if (Process(UshortPaths[index], out response)) if (Process(UshortPaths[index], out response)) {
{
ushort val; ushort val;
try { val = Convert.ToUInt16(response); } try { val = Convert.ToUInt16(response); } catch { val = 0; }
catch { val = 0; }
OnUShortChange(val, index, JsonToSimplConstants.UshortValueChange); OnUShortChange(val, index, JsonToSimplConstants.UshortValueChange);
} }
else else { }
OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange); // OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange);
} }
// Processes the path to a string property and fires of a StringChange event. // Processes the path to a string property and fires of a StringChange event.
@@ -146,8 +147,8 @@ namespace PepperDash.Core.JsonToSimpl
string response; string response;
if (Process(StringPaths[index], out response)) if (Process(StringPaths[index], out response))
OnStringChange(response, index, JsonToSimplConstants.StringValueChange); OnStringChange(response, index, JsonToSimplConstants.StringValueChange);
else else { }
OnStringChange("", index, JsonToSimplConstants.StringValueChange); // OnStringChange("", index, JsonToSimplConstants.StringValueChange);
} }
/// <summary> /// <summary>

View File

@@ -106,7 +106,9 @@ namespace PepperDash.Core.JsonToSimpl
/// <param name="child"></param> /// <param name="child"></param>
public void AddChild(JsonToSimplChildObjectBase child) public void AddChild(JsonToSimplChildObjectBase child)
{ {
if (Children.Contains(child)) return; if (Children.Contains(child)) {
Children.Remove(child);
}
Children.Add(child); Children.Add(child);
} }