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 { /// /// The unique idendifier for the device /// [JsonProperty("key", Required = Required.Always)] public string Key { get; set; } /// /// 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 /// [JsonProperty("uid")] public int Uid { get; set; } /// /// The name of the device /// [JsonProperty("name")] public string Name { get; set; } /// /// The group for the device /// [JsonProperty("group")] public string Group { get; set; } /// /// The type of the device to instantiate /// [JsonProperty("type", Required = Required.Always)] public string Type { get; set; } /// /// The properties necessary to define the device /// [JsonProperty("properties", Required = Required.Always)] [JsonConverter(typeof(DevicePropertiesConverter))] public JToken Properties { get; set; } } /// /// /// 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"); } } }