//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- public IoTValue(string item_id, XmlNode node) { ITEM_ID = item_id; VALUE = node.InnerText; UNIT = node.Attributes["unit"]?.Value; // Fall back to a string value if parsing fails: TYPE = IoTValueType.STRING; Enum.TryParse(node.Attributes["type"]?.Value, out TYPE); }
public IoTValue(Field field) { if (field.value is bool) { TYPE = IoTValueType.BOOLEAN; VALUE = field.value is bool b && b ? "1" : "0"; } else { TYPE = IoTValueType.NONE; VALUE = field.value.ToString(); } UNIT = null; }