mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-15 20:54:46 +00:00
Added AppendToPathPrefix to JSON array modules, to facilitate array lookup modules chained together; corresponds to 2.4.1 modules
This commit is contained in:
@@ -13,6 +13,7 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
public const ushort BoolValueChange = 1;
|
public const ushort BoolValueChange = 1;
|
||||||
public const ushort UshortValueChange = 101;
|
public const ushort UshortValueChange = 101;
|
||||||
public const ushort StringValueChange = 201;
|
public const ushort StringValueChange = 201;
|
||||||
|
public const ushort FullPathToArrayChange = 202;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************//
|
//**************************************************************************************************//
|
||||||
|
|||||||
@@ -12,9 +12,19 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
{
|
{
|
||||||
public string SearchPropertyName { get; set; }
|
public string SearchPropertyName { get; set; }
|
||||||
public string SearchPropertyValue { get; set; }
|
public string SearchPropertyValue { get; set; }
|
||||||
|
public string AppendToPathPrefix { get; set; }
|
||||||
|
|
||||||
int ArrayIndex;
|
int ArrayIndex;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For <2.4.1 array lookups
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="pathPrefix"></param>
|
||||||
|
/// <param name="pathSuffix"></param>
|
||||||
|
/// <param name="searchPropertyName"></param>
|
||||||
|
/// <param name="searchPropertyValue"></param>
|
||||||
public void Initialize(string file, string key, string pathPrefix, string pathSuffix,
|
public void Initialize(string file, string key, string pathPrefix, string pathSuffix,
|
||||||
string searchPropertyName, string searchPropertyValue)
|
string searchPropertyName, string searchPropertyValue)
|
||||||
{
|
{
|
||||||
@@ -24,6 +34,27 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For newer >=2.4.1 array lookups.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="pathPrefix"></param>
|
||||||
|
/// <param name="pathAppend"></param>
|
||||||
|
/// <param name="pathSuffix"></param>
|
||||||
|
/// <param name="searchPropertyName"></param>
|
||||||
|
/// <param name="searchPropertyValue"></param>
|
||||||
|
public void Initialize(string file, string key, string pathPrefix, string pathAppend, string pathSuffix,
|
||||||
|
string searchPropertyName, string searchPropertyValue)
|
||||||
|
{
|
||||||
|
base.Initialize(file, key, pathPrefix, pathSuffix);
|
||||||
|
SearchPropertyName = searchPropertyName;
|
||||||
|
SearchPropertyValue = searchPropertyValue;
|
||||||
|
AppendToPathPrefix = pathAppend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//PathPrefix+ArrayName+[x]+path+PathSuffix
|
//PathPrefix+ArrayName+[x]+path+PathSuffix
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -32,9 +63,11 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override string GetFullPath(string path)
|
protected override string GetFullPath(string path)
|
||||||
{
|
{
|
||||||
return string.Format("{0}[{1}].{2}{3}",
|
return string.Format("{0}[{1}]{2}.{3}{4}",
|
||||||
PathPrefix == null ? "" : PathPrefix,
|
PathPrefix == null ? "" : PathPrefix,
|
||||||
ArrayIndex, path,
|
ArrayIndex,
|
||||||
|
GetPathAppend(),
|
||||||
|
path,
|
||||||
PathSuffix == null ? "" : PathSuffix);
|
PathSuffix == null ? "" : PathSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +77,31 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
base.ProcessAll();
|
base.ProcessAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides the path append for GetFullPath
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetPathAppend()
|
||||||
|
{
|
||||||
|
var a = AppendToPathPrefix;
|
||||||
|
if (string.IsNullOrEmpty(a))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (a.StartsWith("."))
|
||||||
|
{
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "." + a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
bool FindInArray()
|
bool FindInArray()
|
||||||
{
|
{
|
||||||
if (Master == null)
|
if (Master == null)
|
||||||
@@ -75,6 +133,7 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
|
|
||||||
this.LinkedToObject = true;
|
this.LinkedToObject = true;
|
||||||
ArrayIndex = array.IndexOf(item);
|
ArrayIndex = array.IndexOf(item);
|
||||||
|
OnStringChange(GetFullPath(""), 0, JsonToSimplConstants.FullPathToArrayChange);
|
||||||
Debug.Console(1, "JSON Child[{0}] Found array match at index {1}", Key, ArrayIndex);
|
Debug.Console(1, "JSON Child[{0}] Found array match at index {1}", Key, ArrayIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,11 +106,11 @@ 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)) {
|
if (!Children.Contains(child))
|
||||||
Children.Remove(child);
|
{
|
||||||
}
|
|
||||||
Children.Add(child);
|
Children.Add(child);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called from the child to add changed or new values for saving
|
/// Called from the child to add changed or new values for saving
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("Pepperdash_Core")]
|
[assembly: AssemblyProduct("Pepperdash_Core")]
|
||||||
[assembly: AssemblyCopyright("Copyright © PepperDash 2019")]
|
[assembly: AssemblyCopyright("Copyright © PepperDash 2019")]
|
||||||
[assembly: AssemblyVersion("1.0.20.*")]
|
[assembly: AssemblyVersion("1.0.21.*")]
|
||||||
|
|||||||
Reference in New Issue
Block a user