mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
fix: add nullable props where necessary
This commit is contained in:
@@ -23,12 +23,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
if (objectType == typeof(ComPort.ComPortSpec))
|
if (objectType == typeof(ComPort.ComPortSpec?))
|
||||||
{
|
{
|
||||||
var newSer = new JsonSerializer();
|
var newSer = new JsonSerializer();
|
||||||
newSer.Converters.Add(new ComSpecPropsJsonConverter());
|
newSer.Converters.Add(new ComSpecPropsJsonConverter());
|
||||||
newSer.ObjectCreationHandling = ObjectCreationHandling.Replace;
|
newSer.ObjectCreationHandling = ObjectCreationHandling.Replace;
|
||||||
return newSer.Deserialize<ComPort.ComPortSpec>(reader);
|
return newSer.Deserialize<ComPort.ComPortSpec?>(reader);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool CanConvert(Type objectType)
|
public override bool CanConvert(Type objectType)
|
||||||
{
|
{
|
||||||
return objectType == typeof(ComPort.ComPortSpec);
|
return objectType == typeof(ComPort.ComPortSpec?);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanRead { get { return true; } }
|
public override bool CanRead { get { return true; } }
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
switch (controlConfig.Method)
|
switch (controlConfig.Method)
|
||||||
{
|
{
|
||||||
case eControlMethod.Com:
|
case eControlMethod.Com:
|
||||||
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig);
|
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams.Value, controlConfig);
|
||||||
break;
|
break;
|
||||||
case eControlMethod.Cec:
|
case eControlMethod.Cec:
|
||||||
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
||||||
@@ -115,7 +115,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var comPar = config.ComParams;
|
var comPar = config.ComParams;
|
||||||
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
|
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
|
||||||
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
|
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
|
||||||
return dev.ComPorts[config.ControlPortNumber];
|
return dev.ComPorts[config.ControlPortNumber.Value];
|
||||||
Debug.LogMessage(LogEventLevel.Information, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -205,11 +205,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
ControlPropertiesConfig
|
ControlPropertiesConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
[JsonProperty("comParams")]
|
[JsonProperty("comParams", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
[JsonConverter(typeof(ComSpecJsonConverter))]
|
[JsonConverter(typeof(ComSpecJsonConverter))]
|
||||||
public ComPort.ComPortSpec ComParams { get; set; }
|
public ComPort.ComPortSpec? ComParams { get; set; }
|
||||||
|
|
||||||
[JsonProperty("cresnetId")]
|
[JsonProperty("cresnetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public string CresnetId { get; set; }
|
public string CresnetId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -231,7 +231,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty("infinetId")]
|
[JsonProperty("infinetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public string InfinetId { get; set; }
|
public string InfinetId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -23,16 +23,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
public string ProjectName { get; set; }
|
public string ProjectName { get; set; }
|
||||||
|
|
||||||
[JsonProperty("showVolumeGauge", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("showVolumeGauge", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public bool ShowVolumeGauge { get; set; }
|
public bool? ShowVolumeGauge { get; set; }
|
||||||
|
|
||||||
[JsonProperty("usesSplashPage", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("usesSplashPage", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public bool UsesSplashPage { get; set; }
|
public bool? UsesSplashPage { get; set; }
|
||||||
|
|
||||||
[JsonProperty("showDate", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("showDate", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public bool ShowDate { get; set; }
|
public bool? ShowDate { get; set; }
|
||||||
|
|
||||||
[JsonProperty("showTime", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("showTime", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public bool ShowTime { get; set; }
|
public bool? ShowTime { get; set; }
|
||||||
|
|
||||||
[JsonProperty("setup", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("setup", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public UiSetupPropertiesConfig Setup { get; set; }
|
public UiSetupPropertiesConfig Setup { get; set; }
|
||||||
@@ -41,13 +41,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
public string HeaderStyle { get; set; }
|
public string HeaderStyle { get; set; }
|
||||||
|
|
||||||
[JsonProperty("includeInFusionRoomHealth", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("includeInFusionRoomHealth", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public bool IncludeInFusionRoomHealth { get; set; }
|
public bool? IncludeInFusionRoomHealth { get; set; }
|
||||||
|
|
||||||
[JsonProperty("screenSaverTimeoutMin", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("screenSaverTimeoutMin", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public uint ScreenSaverTimeoutMin { get; set; }
|
public uint? ScreenSaverTimeoutMin { get; set; }
|
||||||
|
|
||||||
[JsonProperty("screenSaverMovePositionIntervalMs", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("screenSaverMovePositionIntervalMs", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public uint ScreenSaverMovePositionIntervalMs { get; set; }
|
public uint? ScreenSaverMovePositionIntervalMs { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -55,17 +55,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// Defaults to 5
|
/// Defaults to 5
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("sourcesOverflowCount", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("sourcesOverflowCount", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public int SourcesOverflowCount { get; set; }
|
public int? SourcesOverflowCount { get; set; }
|
||||||
|
|
||||||
public CrestronTouchpanelPropertiesConfig()
|
public CrestronTouchpanelPropertiesConfig() : this(false) { }
|
||||||
|
|
||||||
|
public CrestronTouchpanelPropertiesConfig(bool setDefaultValues = false)
|
||||||
{
|
{
|
||||||
|
if(!setDefaultValues) { return; }
|
||||||
SourcesOverflowCount = 5;
|
SourcesOverflowCount = 5;
|
||||||
HeaderStyle = CrestronTouchpanelPropertiesConfig.Habanero;
|
HeaderStyle = Habanero;
|
||||||
|
|
||||||
// Default values
|
// Default values
|
||||||
ScreenSaverTimeoutMin = 5;
|
ScreenSaverTimeoutMin = 5;
|
||||||
ScreenSaverMovePositionIntervalMs = 15000;
|
ScreenSaverMovePositionIntervalMs = 15000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "habanero"
|
/// "habanero"
|
||||||
|
|||||||
Reference in New Issue
Block a user