mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-29 04:15:00 +00:00
84 lines
2.3 KiB
C#
84 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Crestron.SimplSharp;
|
|
using Crestron.SimplSharp.CrestronIO;
|
|
using Crestron.SimplSharpPro;
|
|
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using PepperDash.Core;
|
|
using PepperDash.Essentials.Core;
|
|
|
|
namespace PepperDash.Essentials.Core.Config
|
|
{
|
|
public class DeviceConfig : PropertiesConfigBase
|
|
{
|
|
/// <summary>
|
|
/// The unique idendifier for the device
|
|
/// </summary>
|
|
[JsonProperty("key", Required = Required.Always)]
|
|
public string Key { get; set; }
|
|
|
|
/// <summary>
|
|
/// A unique ID for each device instance. Used to differentiate between devices of the same type that may have
|
|
/// been added/removed from the system
|
|
/// </summary>
|
|
[JsonProperty("uid")]
|
|
public int Uid { get; set; }
|
|
|
|
/// <summary>
|
|
/// The name of the device
|
|
/// </summary>
|
|
[JsonProperty("name")]
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// The group for the device
|
|
/// </summary>
|
|
[JsonProperty("group")]
|
|
public string Group { get; set; }
|
|
|
|
/// <summary>
|
|
/// The type of the device to instantiate
|
|
/// </summary>
|
|
[JsonProperty("type", Required = Required.Always)]
|
|
public string Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// The properties necessary to define the device
|
|
/// </summary>
|
|
[JsonProperty("properties", Required = Required.Always)]
|
|
[JsonConverter(typeof(DevicePropertiesConverter))]
|
|
public JToken Properties { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class DevicePropertiesConverter : JsonConverter
|
|
{
|
|
|
|
public override bool CanConvert(Type objectType)
|
|
{
|
|
return objectType == typeof(JToken);
|
|
}
|
|
|
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
|
{
|
|
return JToken.ReadFrom(reader);
|
|
}
|
|
|
|
public override bool CanWrite
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
{
|
|
throw new NotImplementedException("Not Supported");
|
|
}
|
|
}
|
|
} |