mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-15 12:44:48 +00:00
Merged in bugfiix/pdc-3 (pull request #6)
Bugfiix/pdc 3 Approved-by: Neil Dorin <ndorin@pepperdash.com> Approved-by: Heath Volmer <hvolmer@pepperdash.com>
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -67,7 +67,7 @@ namespace PepperDash.Core.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="doubleConfig"></param>
|
/// <param name="doubleConfig"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
static JObject MergeConfigs(JObject doubleConfig)
|
public static JObject MergeConfigs(JObject doubleConfig)
|
||||||
{
|
{
|
||||||
var system = JObject.FromObject(doubleConfig["system"]);
|
var system = JObject.FromObject(doubleConfig["system"]);
|
||||||
var template = JObject.FromObject(doubleConfig["template"]);
|
var template = JObject.FromObject(doubleConfig["template"]);
|
||||||
@@ -114,28 +114,35 @@ namespace PepperDash.Core.Config
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Merges the contents of a base and a delta array, matching the entries on a top-level property
|
/// Merges the contents of a base and a delta array, matching the entries on a top-level property
|
||||||
/// given by propertyName. Returns a merge of them. Items in the delta array that do not have
|
/// given by propertyName. Returns a merge of them. Items in the delta array that do not have
|
||||||
/// a matched item in base array will not be merged.
|
/// a matched item in base array will not be merged. Non keyed system items will replace the template items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static JArray MergeArraysOnTopLevelProperty(JArray a1, JArray a2, string propertyName, string path)
|
static JArray MergeArraysOnTopLevelProperty(JArray a1, JArray a2, string propertyName, string path)
|
||||||
{
|
{
|
||||||
var result = new JArray();
|
var result = new JArray();
|
||||||
if (a2 == null)
|
if (a2 == null || a2.Count == 0) // If the system array is null or empty, return the template array
|
||||||
result = a1;
|
return a1;
|
||||||
else if (a1 != null)
|
else if (a1 != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < a1.Count(); i++)
|
if (a2[0]["key"] == null) // If the first item in the system array has no key, overwrite the template array
|
||||||
{
|
{ // with the system array
|
||||||
var a1Dev = a1[i];
|
return a2;
|
||||||
// Try to get a system device and if found, merge it onto template
|
}
|
||||||
var a2Match = a2.FirstOrDefault(t => t[propertyName].Equals(a1Dev[propertyName]));// t.Value<int>("uid") == tmplDev.Value<int>("uid"));
|
else // The arrays are keyed, merge them by key
|
||||||
if (a2Match != null)
|
{
|
||||||
{
|
for (int i = 0; i < a1.Count(); i++)
|
||||||
var mergedItem = Merge(a1Dev, a2Match, string.Format("{0}[{1}].", path, i));// Merge(JObject.FromObject(a1Dev), JObject.FromObject(a2Match));
|
{
|
||||||
result.Add(mergedItem);
|
var a1Dev = a1[i];
|
||||||
}
|
// Try to get a system device and if found, merge it onto template
|
||||||
else
|
var a2Match = a2.FirstOrDefault(t => t[propertyName].Equals(a1Dev[propertyName]));// t.Value<int>("uid") == tmplDev.Value<int>("uid"));
|
||||||
result.Add(a1Dev);
|
if (a2Match != null)
|
||||||
}
|
{
|
||||||
|
var mergedItem = Merge(a1Dev, a2Match, string.Format("{0}[{1}].", path, i));// Merge(JObject.FromObject(a1Dev), JObject.FromObject(a2Match));
|
||||||
|
result.Add(mergedItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result.Add(a1Dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,21 @@ namespace PepperDash.Core
|
|||||||
LoadMemory();
|
LoadMemory();
|
||||||
Level = Contexts.GetOrCreateItem("DEFAULT").Level;
|
Level = Contexts.GetOrCreateItem("DEFAULT").Level;
|
||||||
|
|
||||||
CrestronLogger.Initialize(2, LoggerModeEnum.RM); // Use RM instead of DEFAULT as not to double-up console messages.
|
try
|
||||||
|
{
|
||||||
|
if (InitialParametersClass.NumberOfRemovableDrives > 0)
|
||||||
|
{
|
||||||
|
CrestronConsole.PrintLine("{0} RM Drive(s) Present.", InitialParametersClass.NumberOfRemovableDrives);
|
||||||
|
CrestronLogger.Initialize(2, LoggerModeEnum.DEFAULT); // Use RM instead of DEFAULT as not to double-up console messages.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CrestronConsole.PrintLine("No RM Drive(s) Present.");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
CrestronConsole.PrintLine("Initializing of CrestronLogger failed: {0}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -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.14.*")]
|
[assembly: AssemblyVersion("1.0.15.*")]
|
||||||
|
|||||||
Reference in New Issue
Block a user