mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
added classes for support of destination lists in configuration.
This commit is contained in:
@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash_Essentials_Core.Devices;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,10 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
[JsonProperty("sourceLists")]
|
[JsonProperty("sourceLists")]
|
||||||
public Dictionary<string, Dictionary<string, SourceListItem>> SourceLists { get; set; }
|
public Dictionary<string, Dictionary<string, SourceListItem>> SourceLists { get; set; }
|
||||||
|
|
||||||
[JsonProperty("tieLines")]
|
[JsonProperty("destinationLists")]
|
||||||
|
public Dictionary<string, Dictionary<string, DestinationListItem>> DestinationLists { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("tieLines")]
|
||||||
public List<TieLineConfig> TieLines { get; set; }
|
public List<TieLineConfig> TieLines { get; set; }
|
||||||
|
|
||||||
[JsonProperty("joinMaps")]
|
[JsonProperty("joinMaps")]
|
||||||
@@ -40,6 +44,14 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
return SourceLists[key];
|
return SourceLists[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return DestinationLists[key];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null
|
/// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -52,12 +64,9 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
var deviceConfig = Devices.FirstOrDefault(d => d.Key.Equals(key));
|
var deviceConfig = Devices.FirstOrDefault(d => d.Key.Equals(key));
|
||||||
|
|
||||||
if (deviceConfig != null)
|
//removed if statement that was here...
|
||||||
return deviceConfig;
|
//DeviceConfig will be null if it's not found in the list
|
||||||
else
|
return deviceConfig;
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
|
namespace PepperDash_Essentials_Core.Devices
|
||||||
|
{
|
||||||
|
public class DestinationListItem
|
||||||
|
{
|
||||||
|
[JsonProperty("sinkYey")]
|
||||||
|
public string SinkKey { get; set; }
|
||||||
|
|
||||||
|
private EssentialsDevice _sinkDevice;
|
||||||
|
|
||||||
|
public EssentialsDevice SinkDevice
|
||||||
|
{
|
||||||
|
get { return _sinkDevice ?? (_sinkDevice = DeviceManager.GetDeviceForKey(SinkKey) as EssentialsDevice); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -31,16 +24,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// Returns the source Device for this, if it exists in DeviceManager
|
/// Returns the source Device for this, if it exists in DeviceManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Device SourceDevice
|
public EssentialsDevice SourceDevice
|
||||||
{
|
{
|
||||||
get
|
get { return _sourceDevice ?? (_sourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as EssentialsDevice); }
|
||||||
{
|
|
||||||
if (_SourceDevice == null)
|
|
||||||
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
|
|
||||||
return _SourceDevice;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Device _SourceDevice;
|
private EssentialsDevice _sourceDevice;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets either the source's Name or this AlternateName property, if
|
/// Gets either the source's Name or this AlternateName property, if
|
||||||
@@ -51,13 +39,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Name))
|
if (!string.IsNullOrEmpty(Name))
|
||||||
{
|
{
|
||||||
if (SourceDevice == null)
|
return Name;
|
||||||
return "---";
|
}
|
||||||
return SourceDevice.Name;
|
|
||||||
}
|
return SourceDevice == null ? "---" : SourceDevice.Name;
|
||||||
return Name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user